在Mac上无法安装@ angular/cli的安装 [英] Install for @angular/cli not working on Mac

查看:273
本文介绍了在Mac上无法安装@ angular/cli的安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用"npm install @ angular/cli -g"设置Angular 2

I'm trying to setup Angular 2 using "npm install @angular/cli -g "

安装后,我看到的唯一警告是UNMET PEER DEPENDENCY rxjs@^5.0.1,然后我安装并重新安装"npm install @ angular/cli -g"

After the install, the only warning I see is the UNMET PEER DEPENDENCY rxjs@^5.0.1, which I then install and reinstall "npm install @angular/cli -g"

无论我做什么,或者我使用n设置了哪个版本的Node,在尝试使用"ng"命令时,我都会不断收到以下消息:

No matter what I do, or what version of Node I setup with n, I keep getting the following message when trying to user the "ng" commands:

zsh:找不到命令:ng

zsh: command not found: ng

我一直在四处张望,还没有找到解决方案.

I've been looking around and have not found a solution for this.

有人遇到这个问题并有什么建议吗?

Has anyone run into this and have any suggestions?

更新:

这似乎不是特定于角度/cli的问题.

It looks like this is not a angular/cli specific issue.

现在,当我尝试在运行良好的现有项目上运行"Grunt"和"Ionic"命令时,会收到相同的消息.

I now see that I get the same message when I try to run "Grunt" and "Ionic" commands on an existing project that was working fine.

zsh:找不到命令:离子性 zsh:找不到命令:咕gr声

zsh: command not found: ionic zsh: command not found: grunt

推荐答案

最有可能的是,全局模块的安装目录不在您的$PATH中,因此对于您的外壳来说是未知的.

Most likely, the directory in which the global modules are installed is not in your $PATH -- and therefore unknown to your shell.

要解决此问题,我们可以为全局node_modules创建一个新目录,配置npm以使用它,然后将该目录添加到您的$PATH中.

To fix this issue, we can create a new directory for global node_modules, configure npm to use it, and add that directory to your $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).

Then, first reinstall the latest npm (npm i -g npm), followed by the global packages you need (npm i -g @angular/cli).

有关PATH的更多信息,请参见以下定义: http://www.linfo.org/path_env_var .html

For more on PATH, see this definition: http://www.linfo.org/path_env_var.html

这篇关于在Mac上无法安装@ angular/cli的安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆