我无法使用 yarn@1.22.10 安装节点模块'node-sass'



我正在编写一个带有element-ui的vue 2项目,我需要安装node-sass模块,但无论我安装哪个版本,它们都失败了。我的电脑运行的是macOS 11.4,如何成功安装node-sass ?webpack版本为4.46.0.

% yarn add node-sass@4
...
1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xxx/Workspace/web/h5/vue-demo/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/usr/local/Cellar/node/16.4.0/bin/node" "/Users/xxx/Workspace/web/h5/vue-demo/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/vorbote/Workspace/web/h5/vue-demo/node_modules/node-sass
gyp ERR! node -v v16.4.0

尝试删除包锁。NPM install again

Node -sass v4不支持Node 16 https://github.com/sass/node-sass#node-version-support-policy

最新更新