[Solved] Node.js v17 npm run dev Error: opensslErrorStack

Node.js 17 version opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ]
Error Messages:

D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui>npm run dev

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

 INFO  Starting development server...
10% building 2/5 modules 3 active ...ader\index.js??ref--13-0!D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\src\main.jsError: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\workspace\ideaproject\RuoYi-Cloud\ruoyi-ui\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at D:\workspace\ideaproject\RuoYi-Cloud\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 v17.1.0

Solution:

The reason for the problem is that OpenSSL has been updated in node.js V17
the solutions are:

1. Solve temporarily and set environment variables

#windows
set NODE_OPTIONS=--openssl-legacy-provider
#linux
export NODE_OPTIONS=--openssl-legacy-provider

2. Lower the version of node.js instead of V17

Read More: