【问题标题】:npm install -g @angular/cli gives error Failed at the uglifyjs-webpack-plugin@0.4.6 postinstall scriptnpm install -g @angular/cli 在 uglifyjs-webpack-plugin@0.4.6 postinstall 脚本出现错误
【发布时间】:2018-06-08 16:31:31
【问题描述】:

我是第一次安装 Angular。我正在使用 Windows 7。 node -v is v8.10.0npm -v is 5.7.1 当我运行命令安装 angular cli 时。

 npm install -g @angular/cli

我收到此错误。导致此错误的原因以及如何在 Windows 上安装 Angular。我不熟悉 npm 和 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

【问题讨论】:

  • 您是否使用管理员权限运行此安装?如果没有,请在管理员命令提示符或 PowerShell 中尝试安装。
  • 我尝试使用管理员命令提示符但同样的错误

标签: angular npm angular-cli


【解决方案1】:

试试这个命令。这可能有效

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

【讨论】:

    【解决方案2】:

    您应该更新您的 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

    【讨论】:

      猜你喜欢
      • 2018-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-01
      • 2019-03-29
      • 2020-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多