提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
打开Vue项目时出现Error: error:0308010C:digital envelope routines::unsupporte&error:03000086:digital envelope routines::initialization error的解决方法
前言
npm run electron:serve
时遇到问题:
- Bundling main process...node:internal/crypto/hash:69
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\lib\NormalModule.js:471:10)
at F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\lib\NormalModule.js:503:5
at F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\lib\NormalModule.js:358:12
at F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at F:\vue\electron\electron-demo\node_modules\vue-cli-plugin-electron-builder\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at F:\vue\electron\electron-demo\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.17.1
参考博客:https://blog.csdn.net/zjjxxh/article/details/127173968
Vue 报错error:0308010C:digital envelope routines::unsupported
和博客不同的时,我在执行 npm run serve
时是没有问题的,但执行 npm run electron: serve
时出错。
方案1:在Windows的console中输入
参考博客方法1,在Windows的console中输入了:
set NODE_OPTIONS=--openssl-legacy-provider
之后执行
F:\vue\electron\electron-demo> npm run electron:serve
> electron-demo@0.1.0 electron:serve
> vue-cli-service electron:serve
INFO Starting development server...
DONE Compiled successfully in 4337ms 09:45:15
App running at:
- Local: http://localhost:8081/
- Network: http://10.110.99.82:8081/
Note that the development build is not optimized.
To create a production build, run npm run build.
\ Bundling main process...
DONE Compiled successfully in 1273ms 09:45:17
File Size Gzipped
dist_electron\index.js 806.56 KiB 177.59 KiB
Images and other types of assets omitted.
Build at: 2023-08-29T01:45:17.491Z - Hash: 2ce3714cb60e42882f09 - Time: 1273ms
INFO Launching Electron...
electron: --openssl-legacy-provider is not allowed in NODE_OPTIONS
是因为你的 NODE_OPTIONS 环境变量中包含了 --openssl-legacy-provider 选项,而这个选项在当前版本的 Node.js v18.17.1中被禁用了。
遇到错误
electron: --openssl-legacy-provider is not allowed in NODE_OPTIONS
参考博客:https://blog.csdn.net/zhu_liu_kun/article/details/130840151
之后又遇到了03000086的问题
方案2:卸载Node.js17+版本,安装Node.js17-版本
-
卸载:控制面板
-
nodejsv16.20.2下载网址: https://nodejs.org/download/release/v16.20.2/
-
下载版本node-v16.20.2-x64.msi
-
运行 npm run electron:serve
-
成功
总结
进入了问题循环,通过重新安装node.js解决