简体   繁体   English

安装 Angular 后搞砸了终端 [改变了我的 zsh $PATH?]

[英]Messed up terminal after installing Angular [altered my zsh $PATH?]

I just installed Angular and after the default installation (as set out here: https://angular.io/guide/setup-local ).我刚刚安装了 Angular,并在默认安装之后(如此处所述: https : //angular.io/guide/setup-local )。 After running the standard commands my terminal would not recognise ng (so I could not use ng new my-app ).运行标准命令后,我的终端将无法识别ng (因此我无法使用ng new my-app )。

To solve this problem I did the following based on a stackoverflow answer:为了解决这个问题,我根据 stackoverflow 的回答做了以下事情:

echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
ng --version

(I had no knowledge of what PATH was when doing this, or what the command I was running did...) (我不知道这样做时 PATH 是什么,或者我正在运行的命令做了什么......)

This worked, and my ng --version returned a result and I was able to build and run an Angular app.这奏效了,我的 ng --version 返回了一个结果,我能够构建和运行一个 Angular 应用程序。

However when I opened a new tab in my terminal all my normal terminal 'styles' (I use zsh) had gone.但是,当我在终端中打开一个新选项卡时,所有正常的终端“样式”(我使用 zsh)都消失了。

新的终端窗口

My friend and I tried to resolve the problem, which he felt might be related to my terminal settings (his 'Command (complete path)' read: /usr/local/bin/zsh , and mine was /bin/zsh ).我和我的朋友试图解决这个问题,他认为这可能与我的终端设置有关(他的“命令(完整路径)”为: /usr/local/bin/zsh ,而我的是/bin/zsh )。 So we tried a few things but none have worked and it might be worse - this included resetting my $PATH based on another stackoverflow answer to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin .因此,我们尝试了一些方法,但都没有奏效,而且情况可能更糟 - 这包括根据/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin另一个 stackoverflow 答案重置我的 $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin

We also switched back and forth from /bin/zsh to /bin/bash to try and resolve things, but this did not do anything.我们还从/bin/zsh来回切换到/bin/bash以尝试解决问题,但这并没有做任何事情。

The current state of things is that I cannot run rails commands where I normally could (for example), also things like ll (which returns zsh: command not found: ll ).当前的状态是我无法在通常可以(例如)的地方运行 rails 命令,也无法运行ll (返回zsh: command not found: ll )。

This is my .zsh_history file:这是我的.zsh_history文件:

which zsh
which bash
cd code
cd
ls
lsa
ls -a
cat .aliases
vi .aliases
sudo v
sudo vi .aliases
npm install -g angular
npm list
npm install -g @angular/cli
cd code
ls
cd JoshInLisbon
cd ..
JoshInLisbon
ls
mkdir Angular
mkdir Rails
cd rails
ls
cd ..
open
open .
cd WALD
ls
ll
lll
ls -a
cat .git
.git
ls
ls -a
cd ..
..
JoshInLisbon
..
JoshInLisbon
ls
cd Angular\ Projects
ng new my-first-app
which ng
which angula
which angular
echo $path
npm -v
which node
node -v
npm install -g @angular/cli
ng --version
brew install node
node -v
brew postinstall node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
npm install -g n
sudo npm install -g n
sudo n stable
brew doctor
npm -v
which brew
which npm
brew -v
brew update
npm -v
npm install npm
npm -v
npm install -g npm
npm install -g @angular/cli
ng --version
npm ls --global --depth 0
npm install -g @angular/cli@latest
echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
ng --version
cat ~/.bashrc
echo $PATH
ng new my-app
ls
my-app
npm outdated
..
npm install --save core-js@^3
my-app
npm install --save core-js@^3
npm install --save-dev "jasmine-core@>=3.5"
ng serve --open
exit
ls
cd code
ls
codesign
code
ls
cd code
ls
cd JoshInLisbon
ls
cd an
cd Angular\ Projects
ls
cd my-app
code
ng
code
code --
ls
cd ..
cd taaalk
cd ..
cd taaalk_edge
echo $PROMPT
zsh --version
chsh -s
ls
cd code
ls
cd JoshInLisbon
chsh -s /bin/bash
ls
zsh --version
ls -a
cat .zshrc
cd .zshrc
echo $PATH
echo $PATH
vim
cat
ls -a
vim .zshrc
vim .bash_profile
~/.MacOSX/environment.plist
echo $PATH
plutil -lint ~/.MacOSX/environment.plist
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
ls
ls -a
cat .zshrc.backup
cd code
cd JoshInLisbon
cd Rails\ Projects
rails new thing
rails new thing
echo $PATH
..
ls ..
cd ..
cd ..
cd
ls -a
cat .zshrc.backup
ls -a
cat .zsh_history
vim .bash_profile
ls -a
vim .zcompdump-jmpb-5.7.1
vim zshrc.backup
cat .zshrc
.zsh_history
vim .zshrc
vim .shell.pre-oh-my-zsh
ll
ll -a

I can see my .zshrc file when I do ls -a , however it is empty.当我执行ls -a ,我可以看到我的.zshrc文件,但它是空的。

This is my .bash_history这是我的.bash_history

ls
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
history
which zch
which zsh
echo path
echo $PATH
cd code
cd JoshInLisbon/
rails new project
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
echo $PAtH
echo $PATH
rails new
npm -version
which zsh
cd ..
cd ~
ls
ls -a
cat .szhrc
cat .zshrc
cat .zshrc
ls -a
cat .bash_profile
echo $PATH
cat .zsh_history
cat .bashrc
export PATH=/Users/joshua/.npm-global/bin:./bin:./node_modules/.bin:/Users/joshua/.rbenv/shims:/Users/joshua/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/usr/local/sbin
echo $PATH
which ruby
which zsh
cd code/
cd JoshInLisbon/
cd Rails\ Projects/
rails new thing
ls
rm -R thing
ls
which brew
which zsh
cd ..
cd 
ls
ls -a
cat .zshrc
cat .zshrc
cat .bash_profile
cat .oh-my-zsh/
cd .oh-my-zsh/
ls
cat .oh-my-zsh.sh
cd 
ls
ls -a
cat .zshrc.backup
echo $ZSH
export ZSH="/Users/joshua/.oh-my-zsh"
echo $ZSH
which rails
ll

This might be my old path?这可能是我的老路? export PATH=/Users/joshua/.npm-global/bin:./bin:./node_modules/.bin:/Users/joshua/.rbenv/shims:/Users/joshua/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/usr/local/sbin

Anyway, you are a hero if you made it this far and if you have any idea what I should do I would be very grateful.不管怎样,如果你能走到这一步,你就是英雄,如果你知道我应该做什么,我将不胜感激。

This was resolved by moving my dotfiles (which contains all my zsh settings) back to the original location.这是通过将我的 dotfiles(包含我的所有 zsh 设置)移回原始位置来解决的。 The change was caused by the re-ordering of many folders.更改是由许多文件夹的重新排序引起的。

I also restored my PATH back to the old one pasted at the bottom of the question.我还将我的 PATH 恢复到粘贴在问题底部的旧路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM