Jetbrains/IDEA/Webstorm下node npm run遇到digital envelope routines::unsupported/ERR_OSSL_EVP_UNSUPPORTED解决

2023-07-29 332点热度 0人点赞 0条评论

问题描述

前端Vue项目使用npm run启动的时候,遇到如下报错,无法启动

Error: error:0308010C:digital envelope routines::unsupported

具体信息如下:

> [email protected] serve
> vue-cli-service serve

 INFO  Starting development server...
10% building 2/3 modules 1 active ...website/node_modules/cache-loader/dist/cjs.js??ref--12-0!/path/to/project/node_modules/babel-loader/lib/index.js!/path/to/project/src/main.jsError: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:138:10)
    at module.exports (/path/to/project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/path/to/project/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/path/to/project/node_modules/webpack/lib/NormalModule.js:471:10)
    at /path/to/project/node_modules/webpack/lib/NormalModule.js:503:5
    at /path/to/project/node_modules/webpack/lib/NormalModule.js:358:12
    at /path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at runSyncOrAsync (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
    at iterateNormalLoaders (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
    at Array.<anonymous> (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/path/to/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /path/to/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active /path/to/project/node_modules/webpack-dev-server/client/index.js?http://192.168.50.19:8080&sockPath=/sockjs-nodenode: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:138:10)
    at module.exports (/path/to/project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/path/to/project/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/path/to/project/node_modules/webpack/lib/NormalModule.js:471:10)
    at /path/to/project/node_modules/webpack/lib/NormalModule.js:503:5
    at /path/to/project/node_modules/webpack/lib/NormalModule.js:358:12
    at /path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/path/to/project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/path/to/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /path/to/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /path/to/project/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' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v20.5.0

问题解决

  • 方法1

在node启动的时候,增加参数:--openssl-legacy-provider

如果是用IDEA/WebStorm启动,如图:

  • 方法2

也可以在package.json的scripts下,增加  NODE_OPTIONS=--openssl-legacy-provider 如下:

"scripts": {
     "serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
},
  • 方法3

在.npmrc文件中(一般在用户目录下,是个隐藏文件,如果没有,就新建文件名是.npmrc的文本文件)

新增一行,内容如下:

node-options="--openssl-legacy-provider"

 

admin

这个人很懒,什么都没留下

文章评论

您需要 登录 之后才可以评论