升级了Node.js v17+ 版本出现的问题。
升级了node.js 版本到 v18.8.0,出现如下错误:
INFO Starting development server...
10% building 2/5 modules 3 active ...e7\fishfish\ruoyi-ui\node_modules\@vue\cli-plugin-eslint\node_modules\eslint-loader\index.js??ref--13-0!D:\code7\fishfish\ruoyi-ui\src\main.jsnode:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (D:\code7\fishfish\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\code7\fishfish\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\code7\fishfish\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\code7\fishfish\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
at D:\code7\fishfish\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
at D:\code7\fishfish\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\code7\fishfish\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (D:\code7\fishfish\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (D:\code7\fishfish\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at D:\code7\fishfish\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at D:\code7\fishfish\ruoyi-ui\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v18.8.0
如果使用的是 visual studio code,在终端处输入
windows系统输入
$env:NODE_OPTIONS="--openssl-legacy-provider"
或
set NODE_OPTIONS=--openssl-legacy-provider
补充:
在终端输入一次只能本次生效,如果想永久生效可以在 package.json 文件中修改对应的 scripts 节点的内容如下:
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
linux输入
export NODE_OPTIONS=--openssl-legacy-provider
最直接的办法
将 node.js 版本降到 v16+