Npm 依赖错误 - node-sass 未安装,抛出错误

时间:2021-05-25 02:31:53

标签: npm package.json node-sass

我使用 node 版本 16.2.0 和 npm 版本 7.13,当我尝试在项目上运行 >npm install 时,出现以下内容,

npm ERR!code 1
npm ERR!path / Users / a.aashiq / Desktop / Projects / sdqui / node_modules / node - sass
npm ERR!command failed
npm ERR!command sh - c node - gyp rebuild ^
  npm ERR!1 error generated.
npm ERR!make: ** * [Release / obj.target / binding / src / binding.o] Error 1
npm ERR!gyp ERR!build error
npm ERR!gyp ERR!stack Error: `make`
failed with exit code: 2
npm ERR!gyp ERR!stack at ChildProcess.onExit(/Users/a.aashiq / Desktop / Projects / sdqui / node_modules / node - gyp / lib / build.js: 262: 23)
npm ERR!gyp ERR!stack at ChildProcess.emit(node: events: 365: 28)
npm ERR!gyp ERR!stack at Process.ChildProcess._handle.onexit(node: internal / child_process: 290: 12)
npm ERR!gyp ERR!System Darwin 20.4 .0
npm ERR!gyp ERR!command "/opt/homebrew/Cellar/node/16.2.0/bin/node"
"/Users/a.aashiq/Desktop/Projects/sdqui/node_modules/.bin/node-gyp"
"rebuild"
npm ERR!gyp ERR!cwd / Users / a.aashiq / Desktop / Projects / sdqui / node_modules / node - sass
npm ERR!gyp ERR!node - v v16 .2 .0
npm ERR!gyp ERR!node - gyp - v v3 .8 .0
npm ERR!gyp ERR!not ok

npm ERR!A complete log of this run can be found in:
  npm ERR!/Users/a.aashiq / .npm / _logs / 2021 - 05 - 25 T02_21_26_977Z - debug.log

我认为 node-sass 包和 node 或 npm 之间存在一些依赖冲突。我在 package.json 文件中使用了 node-sass 包版本 "node-sass": "^4.14.1",。它之前运行良好,我更新了我的 mac ,从那时起它就显示了这个错误。我通过 brew 安装了节点。如果它解决了,它将有很大帮助。提前致谢!

1 个答案:

答案 0 :(得分:0)

由于我使用 CRA 和最新 16.x 的节点版本(我从 brew 安装的错误),发生了一些 deps 冲突,所以我从 brew 卸载了节点并设法安装了 LTS 节点 v 并重建了 sass 加载器,它起作用了。谢谢