npm install报错:ERR! configure error gyp ERR! stack Error `gyp` failed with exit c



npm install 运行,报错如下:

   1
   2  gyp ERR! configure error
   3  gyp ERR! stack Error: `gyp` failed with exit code: 1
   4  gyp ERR! stack     at ChildProcess.onCpExit (D:\project\vue-cli3 demo\node_modules\node-
     gyp\l
   5  ib\configure.js:345:16)
   6  gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
   7  gyp ERR! stack     at Process.ChildProcess._handle.onexit
     (internal/child_process.js:277:12)
   8  gyp ERR! System Windows_NT 10.0.19042
   9  gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\project\\vue-cli3
     demo\\node_modu
  10  les\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--
     libsass_cflags=" "
  11  --libsass_ldflags=" "--libsass_library="
  12  gyp ERR! cwd D:\project\vue-cli3 demo\node_modules\node-sass
  13  gyp ERR! node -v v14.15.1
  14  gyp ERR! node-gyp -v v3.8.0
  15  gyp ERR! not ok
  16  Build failed with error code: 1
  17  npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
  18  npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11:
     wante
  19  d {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
  20
  21  npm ERR! code ELIFECYCLE
  22  npm ERR! errno 1
  23  npm ERR! node-sass@4.13.1 postinstall: `node scripts/build.js`
  24  npm ERR! Exit status 1
  25  npm ERR!
  26  npm ERR! Failed at the node-sass@4.13.1 postinstall script.
  27  npm ERR! This is probably not a problem with npm. There is likely additional logging
     output a
  28  bove.
  29
  30  npm ERR! A complete log of this run can be found in:
  31  npm ERR!     C:\Users\小蠢蛋\AppData\Roaming\npm-cache\_logs\2021-04-02T01_28_44_774Z-
     debug.log

试过了 如下办法:

1
  删除 .node-gyp/
2  执行 npm i -g node-gyp
3  删除 项目/node_modules
4  执行 npm i -d

最后 发现是 node-sass 安装源的问题,运行如下:

1
  npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass

成功