场景
我启动vue项目遇到一个错误 “Error: error:0308010C:digital envelope routines::unsupported”
异常信息
> vueblog-vue@0.1.0 serve > vue-cli-service serve INFO Starting development server... 10% building 2/2 modules 0 active(node:8976) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated. (Use `node --trace-deprecation ...` to show where the warning was created) 10% building 2/5 modules 3 active ...ce\MyTest\vueblog\vueblog-vue\node_modules\babel-loader\lib\index.js!D:\myworkspace\MyTest\vueblog\vueblog-vue\src\main.js E rror: 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:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\util\createHash.js:135:53) at NormalModule._initBuildHash (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:417:16) at handleParseError (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:471:10) at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:503:5 at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:358:12 at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3 at iterateNormalLoaders (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10) at iterateNormalLoaders (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:221:10) at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:236:3 at runSyncOrAsync (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:130:11) at iterateNormalLoaders (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:232:2) at Array.<anonymous> (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4) at Storage.finished (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16) at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9 node: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:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\util\createHash.js:135:53) at NormalModule._initBuildHash (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:417:16) at handleParseError (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:471:10) at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:503:5 at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\webpack\lib\NormalModule.js:358:12 at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3 at iterateNormalLoaders (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10) at Array.<anonymous> (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4) at Storage.finished (D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16) at D:\myworkspace\MyTest\vueblog\vueblog-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9 at D:\myworkspace\MyTest\vueblog\vueblog-vue\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.15.0
原因
你好,这是Bing。我可以帮你解决这个错误。根据我的搜索结果,这个错误是由于Node.js V17版本中最近发布的OpenSSL3.0导致的,而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成影响⁴。有以下几种可能的解决方法:
- 降低Node.js的版本,比如使用16.0.0¹。
- 在运行命令中添加**–openssl-legacy-provider**参数,比如
vue-cli-service electron:serve --openssl-legacy-provider
²。
- 在package.json中添加nodeOptions字段,比如
"nodeOptions": "--openssl-legacy-provider"
³。
你可以尝试以上方法,或者告诉我你想要了解更多的内容。
结果
成功
参考:
(1) 如何解决npm run serve运行vue项目时,出现报错:Error: error:0308010C:digital envelope … https://blog.csdn.net/sunyctf/article/details/128504897.
(2) How to resolve "Error: error:0308010C:digital envelope routines … https://stackoverflow.com/questions/74548318/how-to-resolve-error-error0308010cdigital-envelope-routinesunsupported-no.
(3) vue.js - Error: error:0308010C:digital envelope routines::unsupported … https://stackoverflow.com/questions/74310712/error-error0308010cdigital-envelope-routinesunsupported-while-trying-to-bui.
(4) Vue 报错error:0308010C:digital envelope routines::unsupported. https://blog.csdn.net/zjjxxh/article/details/127173968.