npm install -g @angular/cli gives error Failed at the uglifyjs-webpack-plugin@0.4.6 postinstall script

时间:2018-03-09 19:05:15

标签: angular npm angular-cli

I am installing angular first time. I am using windows 7. node -v is v8.10.0 and npm -v is 5.7.1 When I run command to install angular cli.

 npm install -g @angular/cli

I get this error. What causes this error and how I can install angular on windows. I am not familiar with npm and angular

\Users\username>npm install -g @angular/cli
\Users\username\ng -> C:\Users\username\node_modules\@angular\cli\bin\ng

node-sass@4.7.2 install C:\Users\username\node_modules\@angular\cli\node_modules\node-sass
node scripts/install.js


uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\username\node_modules\@angular\cli\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

m WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\@angular\cli\node_modules\fsevents):
m WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
m WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 (node_modules\@angular\cli\node_modules\node-sass):
m WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 install: `node scripts/install.js`
m WARN optional SKIPPING OPTIONAL DEPENDENCY: spawn bash ENOENT

m ERR! file bash
m ERR! path bash
m ERR! code ELIFECYCLE
m ERR! errno ENOENT
m ERR! syscall spawn bash
m ERR! uglifyjs-webpack-plugin@0.4.6 postinstall: `node lib/post_install.js`
m ERR! spawn bash ENOENT
m ERR!
m ERR! Failed at the uglifyjs-webpack-plugin@0.4.6 postinstall script.
m ERR! This is probably not a problem with npm. There is likely additional logging output above.

m ERR! A complete log of this run can be found in:
m ERR!     C:\Users\username\AppData\Roaming\npm-cache\_logs\2018-03-09T15_29_18_155Z-debug.log

2 个答案:

答案 0 :(得分:0)

尝试此命令。这可能有用

  npm rebuild pck-name 
for ex-
    npm rebuild node-sass

答案 1 :(得分:0)

你应该更新你的npm版本并尝试之后。

从这个回答:How can I update npm on Windows?
在Windows上:
以管理员身份运行PowerShell

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade

或者它不起作用,只需Download并运行最新的MSI。请务必下载适合其架构的安装程序。

之后,运行npm install -g @angular/cli

如果您使用的是Linux,只需运行npm install -g npm

即可更新npm