node-sass與node版本映射問題
更新時間:2026年05月12日 10:30:42 作者:白鴿呀
文章提到因Node.js版本不匹配導(dǎo)致node-sass安裝出現(xiàn)問題,需將node版本升級到6.x才能安裝成功,這是根據(jù)個人經(jīng)驗總結(jié)出來的解決方法,供開發(fā)者們在遇到類似問題時提供參考
背景
版本不匹配,比如在node16上面安裝node-sass 4.x
就可能會報以下錯誤
npm ERR! & npm ERR! 2 warnings generated. npm ERR! In file included from ../src/binding.cpp:1: npm ERR! In file included from ../../nan/nan.h:58: npm ERR! In file included from /Users/chris/.node-gyp/16.13.1/include/node/node.h:63: npm ERR! In file included from /Users/chris/.node-gyp/16.13.1/include/node/v8.h:30: npm ERR! /Users/chris/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'? npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data); npm ERR! ~~~~~^~~~~~~~~~~ npm ERR! remove_cv npm ERR! /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.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/chris/Java/datax-web-ui/node_modules/node-gyp/lib/build.js:262:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390: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/chris/Java/datax-web-ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" npm ERR! gyp ERR! cwd /Users/chris/Java/datax-web-ui/node_modules/node-sass npm ERR! gyp ERR! node -v v16.13.1 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/chris/.npm/_logs/2021-12-20T01_39_51_471Z-debug.log
項目中 node-sass 版本為4.x
本地node為14,但是服務(wù)器安裝的node版本是 16,要求node-sass版本為 6.x,更換node即可。

總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
nodejs密碼加密中生成隨機(jī)數(shù)的實例代碼
本篇文章主要介紹了nodejs密碼加密中生成隨機(jī)數(shù)的實例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07
node.js連接mongoDB數(shù)據(jù)庫 快速搭建自己的web服務(wù)
這篇文章主要為大家詳細(xì)介紹了node.js連接mongoDB數(shù)據(jù)庫,如何快速搭建自己的web服務(wù),感興趣的小伙伴們可以參考一下2016-04-04
基于node.js依賴express解析post請求四種數(shù)據(jù)格式
本篇文章主要介紹了node.js依賴express解析post請求四種數(shù)據(jù)格式,主要是www-form-urlencoded,form-data,application/json,text/xml,有興趣的可以了解一下。2017-02-02

