背景
三年前的一个vue3项目,当时用的14版本开发的,最近想把它接入到我的主应用中,在启动中,由于自己用的node版本是16+,导致安装依赖的时候,发生了报错
具体报错内容
npm WARN deprecated node-sass@4.14.1: Node Sass is no longer supported. Please use `sass` or `sass-embedded` instead.
npm WARN deprecated eslint@6.8.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.
npm ERR! code 1
npm ERR! path /Users/gaoyongpeng/test-error/constellation-pro/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c -- node scripts/build.js
npm ERR! Building: /Users/gaoyongpeng/.nvm/versions/node/v16.20.2/bin/node /Users/gaoyongpeng/test-error/constellation-pro/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 '/Users/gaoyongpeng/.nvm/versions/node/v16.20.2/bin/node',
npm ERR! gyp verb cli '/Users/gaoyongpeng/test-error/constellation-pro/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.20.2 | darwin | arm64
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 WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
npm ERR! gyp verb download using dist-url https://npmmirror.com/mirrors/node
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 (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /Users/gaoyongpeng/test-error/constellation-pro/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:202: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 i
发生类似这样的报错,我们可以看在报错之前的正常日志
node-sass@4.14.1: Node Sass is no longer supported. Please use sass
or sass-embedded
instead.
- 这里明显的给出,package.json中的node-sass依赖在当前node环境下,不再支持使用,让我们替换为
sass
orsass-embedded
解决方案
根据提示,替换适合自己的依赖即可,这里我们针对sass就使用sass
就可以了。
写在最后
如果有帮到大家,记得给博主点个赞!