node.js

关注公众号 jb51net

关闭
首页 > 网络编程 > JavaScript > node.js > nodejs版本过高vue-cli无法运行

nodejs版本过高导致vue-cli项目无法正常运行的几种解决方案

作者:Litsev

这篇文章主要给大家介绍了关于nodejs版本过高导致vue-cli项目无法正常运行的几种解决方案,在项目中你可能需要用到的node版本太低,但是你所下的node版本是最新的,这时候就会报错,需要的朋友可以参考下

报错信息:

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:\project\cylink-ui\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\project\cylink-ui\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\project\cylink-ui\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\project\cylink-ui\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\project\cylink-ui\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (D:\project\cylink-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\project\cylink-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\project\cylink-ui\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:\project\cylink-ui\node_modules\webpack\lib\util\createHash.js:135:53)
    at D:\project\cylink-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.13.0

由于nodejs版本过高,导致vue-cli项目运行报错。

解决方案1:每次启动项目前,输入配置命令:

set NODE_OPTIONS=--openssl-legacy-provider 

解决方案2:修改package.json配置文件:

修改前:

修改后:

 修改内容:

"dev": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --open",
"build:prod": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --report",
"build:stage": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode staging",
"preview": "set NODE_OPTIONS=--openssl-legacy-provider && node build/index.js --preview",

总结 

到此这篇关于nodejs版本过高导致vue-cli项目无法正常运行的几种解决方案的文章就介绍到这了,更多相关nodejs版本过高vue-cli无法运行内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文