Node-sass 安装时的坑
clone 的一个项目环境依赖中有 node-sass:

直接 npm install 报错:
npm ERR! /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:710:50: note: 'remove_cv' declared here
npm ERR! template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
npm ERR! ^
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/d3j/Documents/Code/nextfibosio/node_modules/node-gyp/lib/build.js:262:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/d3j/Documents/Code/nextfibosio/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/d3j/Documents/Code/nextfibosio/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.5.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/d3j/.npm/_logs/2021-08-03T10_48_35_880Z-debug.log
在网上找了许多方法都不可行,最后在找到了类似的问题:node.js - error: no template named ‘remove_cv_t’ in namespace ‘std’; did you mean ‘remove_cv’? - Stack Overflow,发现是依赖中 node-sass 的版本不支持 Node.js16 ,只能在 15 及以下的环境下运行,通过 node 版本控制器 n 对使用的 node 进行降级就可以正常安装 node-sass ,安装当前 node 的稳定版本就可以正常使用,使用教程见n - npm (npmjs.com)
|