作者:阿尼陀佛1314 | 来源:互联网 | 2023-02-11 13:55
我正在尝试使用“ npm install @ angular / cli -g”设置Angular 2。
安装后,我看到的唯一警告是UNMET PEER DEPENDENCY rxjs@^5.0.1,然后我安装并重新安装“ npm install @ angular / cli -g”
无论我做什么,或者我使用n设置了哪个版本的Node,在尝试使用“ ng”命令时,我都会不断收到以下消息:
zsh:找不到命令:ng
我一直在环顾四周,还没有找到解决方案。
有没有人碰到这个,有什么建议吗?
更新:
看来这不是与角度/ cli有关的问题。
现在,当我尝试在运行良好的现有项目上运行“ Grunt”和“ Ionic”命令时,会收到相同的消息。
zsh:找不到命令:离子zsh:找不到命令:咕unt
1> Sinan Bolel..:
最有可能的是,全局模块的安装目录不在您的目录中,$PATH
因此对于您的外壳来说是未知的。
要解决此问题,我们可以为全局node_modules创建一个新目录,配置npm
为使用它,然后将该目录添加到您的中$PATH
。
# create a new directory where npm will install packages
$ mkdir ~/.node_modules
# set npm "prefix" config to that directory
$ npm config set prefix '~/.node_modules'
# append a line to your .zshrc instructing it to include that directory in your $PATH, making the executables known to the shell
$ echo 'export PATH=~/.node_modules/bin:$PATH' >> ~/.zshrc
# update current shell with new path (not needed for new sessions)
$ source ~/.zshrc
然后,首先重新安装最新的npm(npm i -g npm
),然后重新安装所需的全局软件包(npm i -g @angular/cli
)。
有关更多信息PATH
,请参见以下定义:http : //www.linfo.org/path_env_var.html