安装在MAC上后出现角度错误

时间:2017-09-24 05:36:17

标签: node.js angular angular-cli mean-stack

我试图在Mac Book Pro上安装MEAN堆栈。 我在安装node和angular-cli之后一直收到错误。

运行命令' ng help,或ng -v'我收到错误:  " ng help   -bash:ng:找不到命令"

以下是我的规格: 节点-v v6.11.3 npm -v 3.10.10 MAC Sierria 10.12.6

我已经在论坛中尝试了几个步骤,并多次卸载并重新安装node和npm。

另外,我尝试过从BREW安装和卸载。我不断得到同样的错误。

是否有正确的方法在MAC上安装MEAN堆栈?特别针对我遇到angular-cli?

的问题

此外,我已根据此网站为我的npm文件夹设置了权限:https://docs.npmjs.com/getting-started/fixing-npm-permissions

3 个答案:

答案 0 :(得分:0)

看起来您没有全局安装@angular/cli。使用-g标志全局安装:

npm i @angular/cli -g

检查全局安装的包运行:

npm ls -depth 0 -g

如果您的列表很长,则可以使用grep缩小范围:

npm ls -depth 0 -g | grep angular

确保您在那里列出了角度CLI。

我个人更喜欢在每个项目本地安装角度CLI并通过 node_modules / .bin 访问它:

node_modules/.bin/ng -v

答案 1 :(得分:0)

在这里找到此内容:https://github.com/angular/angular-cli/issues/5021 为我工作。

npm install -g @angular/cli

Make sure the ng path is correct
    cd ~/npm-global/bin
    ls and make sure ng exists

create .bashrc file on your home directory
    touch ~/.bashrc
    vim ~/.bashrc

Add ng as alias
    press a (enables edit mode) then type in the following
    alias ng="~/npm-global/bin/ng"
    press esc (to get out of edit mode) then :wq (in vim will save)

Temporarily Update .bashrc reference
Your terminal wont take bash updates until a restart but the following command will let you use the updates during the terminal session:
    source ~/.bashrc

Check that ng works
    ng --version

答案 2 :(得分:-1)

npm install -g @ angular / cli

https://github.com/angular/angular-cli/blob/master/README.md

如果您的节点有问题,则可能需要nvm