热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在Mac上无法安装@angular/cli

如何解决《在Mac上无法安装@angular/cli》经验,为你挑选了1个好方法。

我正在尝试使用“ 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


推荐阅读
author-avatar
阿尼陀佛1314
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有