当多个项目使用的node版本不同时,使用nvm 管理多个不同node版本,在其他项目需要安装依赖时需要切换到对应的node版本后再安装,否则会报错。并且node版本需要对应支持node-saas的版本才行。
版本对应表:
node版本 | node-sass版本 |
node 16 | 6.0+ |
node 15 | 5.0+ |
node 14 | 4.14+ |
node 13 | 4.13+,<5.0 |
node 12 | 4.12+ |
node 11 | 4.10+,<5.0 |
node 10 | 4.9+,<5.0 |
node 8 | 4.5.3+,<5.0 |
node <8 | <5.0 |
sass-loader版本 | node-sass版本 |
sass-loader 4.1.1 | node-sass 4.3.0 |
sass-loader 7.0.3 | node-sass 4.7.2 |
sass-loader 7.3.1 | node-sass 4.7.2 |
sass-loader 7.3.1 | node-sass 4.14.1 |
sass-loader 10.0.1 | node-sass 6.0.1 |
出现原因
必须要对应才行,否则会报错
当不同版本node对应的项目需要重装依赖时,忘记切换对应node版本就安装依赖,结果报错如下:
gyp ERR! cwd D:\wms\zh-twms-ui\node_modules\node-sass npm ERR!
gyp ERR! node -v v16.0.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
知道了是node版本的问题后使用nvm切换版本到12.0.0后再安装,安装依赖正常,但是运行项目时报错了,如下:
#
# Fatal error in , line 0
# Check failed: U_SUCCESS(status).
#
#
#
#FailureMessage Object: 00000000001BD590npm ERR! code ELIFECYCLE
npm ERR! errno 3221225477
npm ERR! twms-app@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 3221225477
npm ERR!
npm ERR! Failed at the twms-app@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2023-01-12T03_03_32_011Z-debug.lo
最后使用node版本为12.1.0安装依赖 再运行就正常了