MacOS 安装 node-sass 报错 no template named ‘remove_cv_t‘

环境:MasOS Mojave
Node命令:npm install node-sass
错误信息:

In file included from ../src/binding.cpp:1:
In file included from ../../_nan@2.14.2@nan/nan.h:56:
In file included from /Users/rumia/.node-gyp/16.2.0/include/node/node.h:63:
In file included from /Users/rumia/.node-gyp/16.2.0/include/node/v8.h:30:
/Users/rumia/.node-gyp/16.2.0/include/node/v8-internal.h:452:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
            !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:665:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
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/rumia/Documents/src/Pixivel-Frontend/node_modules/_node-gyp@3.8.0@node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node/16.2.0/bin/node" "/Users/rumia/Documents/src/Pixivel-Frontend/node_modules/_node-gyp@3.8.0@node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/rumia/Documents/src/Pixivel-Frontend/node_modules/_node-sass@4.14.1@node-sass
gyp ERR! node -v v16.2.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
[npminstall:runscript:error] node-sass@^4.9.0 scripts.postinstall run "node scripts/build.js" error: Error [RunScriptError]: Run "sh -c node scripts/build.js" error, exit code 1
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
    at ChildProcess.emit (node:events:365:28)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  stdio: [Object],
  exitcode: 1
}
✖ Install fail! RunScriptError: post install error, please remove node_modules before retry!
Run "sh -c node scripts/build.js" error, exit code 1
RunScriptError: Run "sh -c node scripts/build.js" error, exit code 1
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
    at ChildProcess.emit (node:events:365:28)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npminstall version: 3.28.0
npminstall args: /usr/local/Cellar/node/16.2.0/bin/node /usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/Users/rumia/.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://registry.nlark.com node-sass

解决方案:~/.node-gyp/16.2.0/include/node/v8-internal.h,将452行的remove_cv_t改为remove_cv,保存后再次安装,此时编译正常通过,安装成功;

阅读 2.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏