简体   繁体   English

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

[英]angular-cli ng error after installing on a MAC

I'm trying to install the MEAN stack on my Mac Book Pro. 我正在尝试在Mac Book Pro上安装MEAN堆栈。 I'm getting an error consistently after install node and angular-cli. 安装节点和angular-cli之后,我始终遇到错误。

when running the command 'ng help, or ng -v' I get the error: "ng help -bash: ng: command not found" . 当运行命令'ng help或ng -v'时,出现错误: “ ng help -bash:ng:command not found”

Here are my specs: node -v v6.11.3 npm -v 3.10.10 MAC Sierria 10.12.6 这是我的规格:node -v v6.11.3 npm -v 3.10.10 MAC Sierria 10.12.6

I've tried several steps in forums and uninstalling and reinstalling node and npm several times. 我已经在论坛中尝试了多个步骤,并多次卸载并重新安装node和npm。

Also, I've tried installing and uninstalling from BREW. 另外,我尝试从BREW安装和卸载。 I keep getting the same error though. 我仍然收到相同的错误。

Is there a correct way to install the MEAN stack on a MAC? 是否有在MAC上安装MEAN堆栈的正确方法? Specifically for the issue I'm experiencing with the angular-cli? 专门针对我遇到的有关cli-cli的问题?

Also, I've set permissions to my npm folders according to this site: https://docs.npmjs.com/getting-started/fixing-npm-permissions 另外,我已经根据以下站点对我的npm文件夹设置了权限: https : //docs.npmjs.com/getting-started/fixing-npm-permissions

it looks like you do not have @angular/cli installed globally. 看来您没有全局安装@angular/cli Use -g flag to install it globally: 使用-g标志将其全局安装:

npm i @angular/cli -g

to check your globally installed packages run: 检查您全局安装的软件包是否运行:

npm ls -depth 0 -g

if your list is very long, you can narrow it with grep : 如果您的列表很长,可以使用grep缩小范围:

npm ls -depth 0 -g | grep angular

make sure that you have angular CLI listed there. 确保在那里列出了角度CLI。

I personally prefer installing angular CLI locally per project and accessing it via node_modules/.bin : 我个人更喜欢每个项目在本地安装angular CLI并通过node_modules / .bin访问它:

node_modules/.bin/ng -v

Found this here: https://github.com/angular/angular-cli/issues/5021 Worked for me. 在这里找到这个: 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

npm install -g @angular/cli npm install -g @ angular / cli

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

if you have problem with your node, you may need nvm 如果您的节点有问题,则可能需要nvm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM