vue项目启动的报错问题

背景

三年前的一个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 or sass-embedded

解决方案

根据提示,替换适合自己的依赖即可,这里我们针对sass就使用sass 就可以了。

写在最后

如果有帮到大家,记得给博主点个赞!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不cong明的亚子

鼓励和支持,是我每滴汗水的见证

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值