node-sass与node版本映射问题

 更新时间:2026年05月12日 10:30:42   作者:白鸽呀  
文章提到因Node.js版本不匹配导致node-sass安装出现问题,需将node版本升级到6.x才能安装成功,这是根据个人经验总结出来的解决方法,供开发者们在遇到类似问题时提供参考

背景

版本不匹配,比如在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,但是服务器安装的node版本是 16,要求node-sass版本为 6.x,更换node即可。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • Nodejs对postgresql基本操作的封装方法

    Nodejs对postgresql基本操作的封装方法

    今天小编就为大家分享一篇Nodejs对postgresql基本操作的封装方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-02-02
  • nodejs密码加密中生成随机数的实例代码

    nodejs密码加密中生成随机数的实例代码

    本篇文章主要介绍了nodejs密码加密中生成随机数的实例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-07-07
  • node.js连接mongoDB数据库 快速搭建自己的web服务

    node.js连接mongoDB数据库 快速搭建自己的web服务

    这篇文章主要为大家详细介绍了node.js连接mongoDB数据库,如何快速搭建自己的web服务,感兴趣的小伙伴们可以参考一下
    2016-04-04
  • npm镜像源证书过期的问题解决

    npm镜像源证书过期的问题解决

    因为npm官方镜像在国内访问很慢,我们基本上都会选择切换到国内的一些npm镜像,本文主要介绍了npm镜像源证书过期的问题解决,具有一定的参考价值,感兴趣的可以了解一下
    2024-07-07
  • 深入解析nodejs HTTP服务

    深入解析nodejs HTTP服务

    本篇文章主要介绍了深入解析nodejs HTTP服务,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-07-07
  • Nodejs Express4.x开发框架随手笔记

    Nodejs Express4.x开发框架随手笔记

    Express: ?web application framework for?Node.js?Express 是一个简洁、灵活的 node.js Web 应用开发框架, 它提供一系列强大的特性,帮助你创建各种 Web 和移动设备应用,本篇文章给大家介绍nodejs express4.x开发框架随手笔记,感兴趣的朋友一起学习吧
    2015-11-11
  • node.js中的fs.truncate方法使用说明

    node.js中的fs.truncate方法使用说明

    这篇文章主要介绍了node.js中的fs.truncate方法使用说明,本文介绍了fs.truncate的方法说明、语法、接收参数、使用实例和实现源码,需要的朋友可以参考下
    2014-12-12
  • 基于node.js依赖express解析post请求四种数据格式

    基于node.js依赖express解析post请求四种数据格式

    本篇文章主要介绍了node.js依赖express解析post请求四种数据格式,主要是www-form-urlencoded,form-data,application/json,text/xml,有兴趣的可以了解一下。
    2017-02-02
  • npm查看镜像源与切换镜像源方法详解

    npm查看镜像源与切换镜像源方法详解

    这篇文章主要为大家介绍了npm查看镜像源与切换镜像源方法详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-06-06
  • 详解Node全局变量global模块

    详解Node全局变量global模块

    这篇文章主要介绍了详解Node全局变量global模块,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-09-09

最新评论