版本适配问题:node-sass与nodejs的版本不对应

本文讲述了NodeJS不同版本与node-sass兼容性问题,提供了解决方法,如升级或降级Node版本,并列出对应版本的依赖。遇到类似错误时,可通过npminstall node-sass@6.0.1来修复。

版本适配问题:node-sass与nodejs的版本不对应。

版本对应列表:

| NodeJS  | Supported node-sass version | Node Module |
|---------|-----------------------------|-------------|
| Node 16 | 6.0+                        | 93          |
| Node 15 | 5.0+                        | 88          |
| Node 14 | 4.14+                       | 83          |
| Node 13 | 4.13+, <5.0                 | 79          |
| Node 12 | 4.12+                       | 72          |
| Node 11 | 4.10+, <5.0                 | 67          |
| Node 10 | 4.9+, <6.0                  | 64          |
| Node 8  | 4.5.3+, <5.0                | 57          |
| Node <8 | <5.0                        | <57         |

报错示范: 

npm ERR! code 1
npm ERR! path D:\项目文件\link-front\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: E:\Program Files\nodejs\node.exe D:\项目文件\link-front\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'E:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\项目文件\\link-front\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb download using dist-url https://npm.taobao.org/dist
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\项目文件\link-front\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\项目文件\link-front\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\项目文件\link-front\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\项目文件\link-front\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\项目文件\link-front\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\项目文件\link-front\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\项目文件\link-front\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\项目文件\link-front\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\项目文件\link-front\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\项目文件\link-front\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\项目文件\link-front\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\项目文件\link-front\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\项目文件\link-front\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python". checking python launcher
npm ERR! gyp verb could not find "python". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\项目文件\link-front\node_modules\node-gyp\lib\configure.js:484:19)npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\项目文件\link-front\node_modules\node-gyp\lib\configure.js:509:16) 
npm ERR! gyp ERR! stack     at callback (D:\项目文件\link-front\node_modules\graceful-fs\polyfills.js:306:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! command "E:\\Program Files\\nodejs\\node.exe" "D:\\项目文件\\link-front\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_code_modules\\node-gyp\\bin\\node-gyflags=" "--libsass_ldflags=" "--libsass_library="                                           sass_library="
npm ERR! gyp ERR! cwd D:\项目文件\link-front\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 i node-sass@6.0.1

[root@VM-16-7-centos UnblockNeteaseMusic]# curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash - # 选v20 LTS版 2025-05-14 13:45:45 - Cleaning up old repositories... 2025-05-14 13:45:45 - Old repositories removed 2025-05-14 13:45:45 - Supported architecture: x86_64 2025-05-14 13:45:45 - Added N|Solid repository for LTS version: 20.x 2025-05-14 13:45:45 - yum available, updating... 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile nodesource-nodejs | 3.0 kB 00:00:00 (1/3): nodesource-nodejs/primary_db | 57 kB 00:00:01 (2/3): nodesource-nodejs/filelists_db | 615 kB 00:00:02 (3/3): nodesource-nodejs/other_db | 7.7 kB 00:00:00 元数据缓存已建立 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile nodesource-nsolid | 3.0 kB 00:00:00 (1/3): nodesource-nsolid/primary_db | 28 kB 00:00:00 (2/3): nodesource-nsolid/other_db | 2.7 kB 00:00:00 (3/3): nodesource-nsolid/filelists_db | 514 kB 00:00:02 元数据缓存已建立 2025-05-14 13:45:53 - Repository is configured and updated. 2025-05-14 13:45:53 - You can use N|solid Runtime as a node.js alternative 2025-05-14 13:45:53 - Run &#39;yum install nsolid -y&#39; to complete the installation. 2025-05-14 13:45:53 - Run &#39;yum install nodejs -y&#39; to complete the installation. [root@VM-16-7-centos UnblockNeteaseMusic]# sudo yum clean all && sudo yum install -y nodejs 已加载插件:fastestmirror, langpacks 正在清理软件源: epel extras nodesource-nodejs nodesource-nsolid os updates Cleaning up list of fastest mirrors 已加载插件:fastestmirror, langpacks Determining fastest mirrors epel | 4.3 kB 00:00:00 extras | 2.9 kB 00:00:00 nodesource-nodejs | 3.0 kB 00:00:00 nodesource-nsolid | 3.0 kB 00:00:00 os | 3.6 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/9): epel/7/x86_64/group | 399 kB 00:00:00 (2/9): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00 (3/9): epel/7/x86_64/primary_db | 8.7 MB 00:00:00 (4/9): os/x86_64/group_gz | 153 kB 00:00:00 (5/9): extras/x86_64/primary_db | 253 kB 00:00:00 (6/9): nodesource-nodejs/primary_db | 57 kB 00:00:00 (7/9): updates/x86_64/primary_db | 27 MB 00:00:00 (8/9): os/x86_64/primary_db | 6.1 MB 00:00:01 (9/9): nodesource-nsolid/primary_db | 28 kB 00:00:01 正在解决依赖关系 There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don&#39;t work you&#39;ll have to try removing/installing packages by hand (maybe package-cleanup can help). --> 正在检查事务 ---> 软件包 nodejs.x86_64.1.16.20.2-1.el7 将被 升级 ---> 软件包 nodejs.x86_64.2.20.19.1-1nodesource 将被 更新 --> 正在处理依赖关系 glibc >= 2.28,它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libm.so.6(GLIBC_2.27)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(CXXABI_1.3.9)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(GLIBCXX_3.4.20)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libstdc++.so.6(GLIBCXX_3.4.21)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 正在处理依赖关系 libc.so.6(GLIBC_2.28)(64bit),它被软件包 2:nodejs-20.19.1-1nodesource.x86_64 需要 --> 解决依赖关系完成 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(GLIBCXX_3.4.20)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:glibc >= 2.28 已安装: glibc-2.17-326.el7_9.3.x86_64 (@updates) glibc = 2.17-326.el7_9.3 可用: glibc-2.17-317.el7.i686 (os) glibc = 2.17-317.el7 可用: glibc-2.17-322.el7_9.i686 (updates) glibc = 2.17-322.el7_9 可用: glibc-2.17-323.el7_9.i686 (updates) glibc = 2.17-323.el7_9 可用: glibc-2.17-324.el7_9.i686 (updates) glibc = 2.17-324.el7_9 可用: glibc-2.17-325.el7_9.i686 (updates) glibc = 2.17-325.el7_9 可用: glibc-2.17-326.el7_9.i686 (updates) glibc = 2.17-326.el7_9 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libm.so.6(GLIBC_2.27)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(CXXABI_1.3.9)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libc.so.6(GLIBC_2.28)(64bit) 错误:软件包:2:nodejs-20.19.1-1nodesource.x86_64 (nodesource-nodejs) 需要:libstdc++.so.6(GLIBCXX_3.4.21)(64bit) 您可以尝试添加 --skip-broken 选项来解决该问题 ** 发现 1 个已存在的 RPM 数据库问题, &#39;yum check&#39; 输出如下: mpi-selector-1.0.3-1.54310.x86_64 是 mpi-selector-1.0.3-1.51258.x86_64 的副本 [root@VM-16-7-centos UnblockNeteaseMusic]# node -v # 验证版本应≥v20.12.2 v16.20.2 [root@VM-16-7-centos UnblockNeteaseMusic]# # CentOS证书默认路径 [root@VM-16-7-centos UnblockNeteaseMusic]# export NODE_EXTRA_CA_CERTS=/etc/pki/tls/certs/ca-bundle.crt [root@VM-16-7-centos UnblockNeteaseMusic]# # 永久生效则写入~/.bashrc [root@VM-16-7-centos UnblockNeteaseMusic]# echo &#39;export NODE_EXTRA_CA_CERTS=/etc/pki/tls/certs/ca-bundle.crt&#39; >> ~/.bashrc [root@VM-16-7-centos UnblockNeteaseMusic]# npm install --verbose fuse.js # 观察下载源是否为npmmirror.com -bash: npm:到命令 [root@VM-16-7-centos UnblockNeteaseMusic]# curl -I https://registry.npmmirror.com # 检查返回200状态码
最新发布
05-15
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值