无法在 Ubuntu 16.04 中安装 Angular CLI

Bek*_*rat 2 node.js angular-cli angular

我无法在 Ubuntu 16.04 中安装 Angular CLI。进入后sudo npm install-g angular-cli,加载和写入需要很长时间。

npm ERR! Linux 4.13.0-37-generic 
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "angular-cli" 
npm ERR! node v4.2.6 
npm ERR! npm v3.5.2 
npm ERR! path /usr/local/bin/ng 
npm ERR! code EEXIST 
npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/@angular/cli/bin/ng symlink target is not controlled by npm /usr/local 
npm ERR! File exists: /usr/local/bin/ng 
npm ERR! Move it away, and try again. 
npm ERR! Please include the following file with any support request: 
npm ERR! /home/dosxanzada/WebstormProjects/meanauthapp/npm-debug.log
Run Code Online (Sandbox Code Playgroud)

npm 错误

节点版本:v9.7.1,npm版本:3.5.2

sma*_*use 5

您需要从“/usr/local/bin”中手动删除“ng”文件夹。

因此运行以下命令:

sudo rm -rf /usr/local/bin/ng
Run Code Online (Sandbox Code Playgroud)

然后再次安装 Angular Cli:

sudo npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

如果第二个命令仍然不起作用,请尝试强制安装添加-f

sudo npm install -g -f @angular/cli
Run Code Online (Sandbox Code Playgroud)

面临同样问题的其他用户可能必须删除/usr/bin/ng而不是/usr/local/bin/ng.