使用npm安装angular/cli时出错

9
当我尝试使用以下命令安装angular cli时:
npm install -g @angular/cli
我遇到了下面提到的错误。
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 
(node_modules\@angular\cli\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:  Unsupported platform for 
fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} 
(current: {"os":"win32","arch":"x64"}) 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.1.2 (node_modules\@angular\cli\node_modules\watchpack\node_modules\chokidar\node_modules\fsevents): 
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.1.2 (node_modules\@angular\cli\node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents): 
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) 
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none was installed. 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.0 (node_modules\@angular\cli\node_modules\node-sass): 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.9.0 postinstall: `node scripts/build.js 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

有任何想法是什么问题?

我的Node版本是6.9.2,npm版本是3.10.9。


升级Node至8.9版本或更高。这是一个新的要求。然后再尝试一遍。 - R. Richards
是的,确实是关于 Node 版本的问题,我卸载了 Node 并安装了 v8.11.1,然后它就可以工作了。谢谢 @R.Richards。 - prady
4个回答

10

5
这个警告说明了一切:
Unsupported platform for fsevents@1.2.4: **wanted** {"os":"darwin","arch":"any"} (**current**: {"os":"win32","arch":"x64"})

只有基于Unix的系统使用fsevents,而您正在使用Windows!


1
我知道只有基于 Unix 的系统受到支持,但我不希望在所有构建中都收到此警告。你知道在 Windows 上如何消除这个警告吗? - Bruno Bieri

0

首先,你发布的所有内容都是警告而不是错误。

这意味着npm已经跳过了依赖项。

如果你将npm版本更新到最新,可以解决这个问题,使用以下命令:

npm i -g npm@latest  

// 如果您遇到权限错误,请使用 sudo

然后再次尝试安装。

希望这可以帮助您。


成功更新npm后,当我尝试重新安装angular/cli时,我会收到以下警告:`npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules@angular\cli\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
  • @angular/cli@6.0.7 updated 1 package in 44.551s`,并且ng -v返回不可识别的命令。
- prady
1
你现在的npm版本是多少? - Harshal Yeole
现在的npm版本是6.1.0。 - prady
尝试运行以下命令:npm i -f -g npm@latest - Harshal Yeole
仍然出现相同的警告,无法识别ng。 - prady
显示剩余2条评论

0
$ npm install -g @angular/cli
C:\Users\Asus\Desktop\ng -> C:\Users\Asus\Desktop\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/cli@7.3.2
added 295 packages from 179 contributors in 120.715s

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接