背景:换电脑了,vue工程也从2.x到3.x,node版本也升级了,今天打开vue2.x的工程却打不开。
报错如下:
> vue-admin-template@4.4.0 dev
> vue-cli-service serve
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
INFO Starting development server...
10% building 2/5 modules 3 active ...les/webpack-dev-server/client/index.js?http://192.168.25.102:9528&sockPath=/sockjs-nodeError: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:80:19)
at Object.createHash (node:crypto:139:10)
at module.exports (/Users/Shared/webset/web-vue/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/Shared/webset/web-vue/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/Shared/webset/web-vue/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
node:internal/crypto/hash:80
this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache());
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:80:19)
at Object.createHash (node:crypto:139:10)
at module.exports (/Users/Shared/webset/web-vue/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/Shared/webset/web-vue/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/Users/Shared/webset/web-vue/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/Shared/webset/web-vue/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/Shared/webset/web-vue/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/Shared/webset/web-vue/node_modules/graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
opensslErrorStack: [
'error:03000086:digital envelope routines::initialization error',
'error:0308010C:digital envelope routines::unsupported'
],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v20.12.0
找到很多说是在 package.json里的 scripts--->dev值的最前面添加 set NODE_OPTIONS=--openssl-legacy-provider &&
"scripts": {
"dev": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
}
添加完还是报一样错,最终发现这个windows系统下的用法,mac的正确配置如下:
"scripts": {
"dev": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
}
搬砖记录一下~