【发布时间】:2020-01-27 23:48:32
【问题描述】:
我查看了此处有关此问题的大量帖子并尝试了它们,但没有成功解决此问题。
我在 MacOS 上,这是我到目前为止根据我在这里找到的建议所做的,但我仍然收到此错误
~~ sudo npm uninstall -g angular-cli
~~ sudo npm uninstall -g @angular/cli
~~ sudo npm cache clean --force
~~ sudo npm install -g @angular/cli
这个输出:
/usr/local/Cellar/node/11.10.0/bin/ng -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli/bin/ng
> @angular/cli@8.3.6 postinstall /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js
+ @angular/cli@8.3.6
added 245 packages from 185 contributors in 8.784s
但是,发出以下命令不起作用:
~~ ng version
-bash: ng: command not found
有些人建议链接,所以我也尝试了:
~~ sudo npm link @angular/cli
,输出如下:
/Users/dinob/node_modules/@angular/cli -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
,但是ng版本还是不行:
~~ ng version
-bash: ng: command not found
许多帖子建议应该在我的 /Users/dinob 目录下创建一个目录.npm-global,但我没有看到它。我只看到.npm 目录,而不是.npm-global。
我也尝试了以下方法:
如上所述卸载 Angular
酿造更新
brew upgrade node // 从 11.10.0 升级到 12.10.0
然后重复上述步骤安装 angular/cli
还是同样的问题,没有找到ng命令
这不是 KenWhite 建议的重复问题,我已经查看了所有关于这个问题的帖子,我可以找到(以及更多),尝试了它们,但没有一个为我解决了这个问题。
sudo npm install -g @angular/cli 命令完成并返回以下路径,但其中没有@angular 目录:
/usr/local/Cellar/node/11.10.0/bin/ng -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli/bin/ng
上面没有bin文件夹:
dinob @ /usr/local/Cellar/node/11.10.0
~~ ls -la
total 80
drwxr-xr-x 8 dinob staff 256 2 Oct 11:30 ./
drwxr-xr-x 5 dinob staff 160 27 Sep 09:29 ../
-rw-r--r--@ 1 dinob staff 8196 2 Oct 11:32 .DS_Store
-rw-r--r-- 1 dinob staff 26696 14 Feb 2019 README.md
drwxr-xr-x 3 dinob staff 96 14 Feb 2019 etc/
drwxr-xr-x 3 dinob staff 96 14 Feb 2019 include/
drwxr-xr-x 5 dinob staff 160 2 Oct 11:22 lib/
drwxr-xr-x 5 dinob staff 160 14 Feb 2019 share/
这个位置> @angular/cli@8.3.6 postinstall /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli:
dinob @ /usr/local/Cellar/node/11.10.0/lib/node_modules
~~ ls -la
total 16
drwxr-xr-x 6 dinob staff 192 2 Oct 11:22 ./
drwxr-xr-x 5 dinob staff 160 2 Oct 11:22 ../
-rw-r--r--@ 1 dinob staff 6148 2 Oct 11:27 .DS_Store
drwxr-xr-x 7 root staff 224 26 Sep 16:42 n/
drwxr-xr-x 26 dinob staff 832 2 Oct 11:28 npm/
drwxr-xr-x 6 dinob staff 192 15 Jul 16:32 react-native-cli/
【问题讨论】:
-
When trying to install angular, ng command is not found 和其他几个的可能重复项,通过在此站点搜索确切的错误消息
bash: ng: command not found很容易找到。 -
@KenWhite 正如解释的那样,我已经搜索并查看了这些帖子,它不是重复的
标签: macos angular-cli