在 mac 上安装 angular 时出错

Erron on installing angular on mac

我尝试使用以下命令在 mac 上安装 Angular CLI

sudo npm install -g @angular/cli

报错如下

/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.4 install /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

sh: node: command not found

> @angular/cli@6.0.8 postinstall /usr/local/lib/node_modules/@angular/cli
> node ./bin/ng-update-message.js

sh: node: command not found
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/@angular/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: spawn ENOENT

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @angular/cli@6.0.8 postinstall: `node ./bin/ng-update-message.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @angular/cli@6.0.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sugunan/.npm/_logs/2018-07-08T01_27_53_465Z-debug.log

如何解决这个问题?

以下命令有效

sudo npm install -g @angular/cli --unsafe-perm=true --allow-root