且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ng:找不到命令

更新时间:2023-11-15 20:41:40

如果其他人像我一样遇到这个问题,这里是我在 MacOS 系统范围内解决它的方法.希望这会有所帮助.

In case others come here with this issue as I have, here is how I solved it system-wide on MacOS. Hope this helps.

验证节点是否已安装:

$ node -v
v11.2.0

验证 npm 是否已安装:

Verify npm is installed:

$ npm -v
6.4.1

验证您的 npm 全局安装文件路径是否已配置(称为 prefix).我的在 ~/.npm-packages 下:

Verify your npm global install file path is configured (known as prefix). Mine is under ~/.npm-packages:

$ npm config ls -l | grep prefix
prefix = "/Users/christiangroleau/.npm-packages"

如果没有,你可以把它放到你的 ~/.npmrc 文件中:

If not, you can place it into your ~/.npmrc file:

echo prefix=~/.npm-packages >> ~/.npmrc

验证您的前缀路径是否列在您的系统路径中:

Verify that your prefix path is listed in your system PATH:

$ echo $PATH
/Users/christiangroleau/.npm-packages/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

如果没有,请调用以下内容:

If not, invoke the following:

export PATH="$HOME/.npm-packages/bin:$PATH"

最后,您可以重新安装 angular-cli(在我的情况下,我需要全局安装它):

Finally, you can reinstall angular-cli (in my case I needed to install it globally):

$ npm install -g @angular/cli

验证安装:

$ ng -v