【npm run serve报错问题node.js版本太高】
作者:mmseoamin日期:2024-01-19


问题描述

提示:这里描述项目中遇到的问题:

npm run serve出现下面的报错问题

Debugger attached.
 INFO  Starting development server...
10% building 2/2 modules 0 active(node:60792) [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 ...ader\index.js??ref--14-2!D:\git\vue3-todo-ts\node_modules\eslint-loader\index.js??ref--13-0!D:\git\vue3-todo-ts\src\main.tsDebugger attached.
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 (D:\git\vue3-todo-ts\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array. (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\git\vue3-todo-ts\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\git\vue3-todo-ts\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
Waiting for the debugger to disconnect...
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:138:10)
    at module.exports (D:\git\vue3-todo-ts\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\git\vue3-todo-ts\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array. (D:\git\vue3-todo-ts\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\git\vue3-todo-ts\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\git\vue3-todo-ts\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at D:\git\vue3-todo-ts\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 v20.0.0
Waiting for the debugger to disconnect...

解决方案:

提示:这里填写该问题的具体解决方案

  • 1、方法一:

    1. 在命令行修改环境变量:$env:NODE_OPTIONS="--openssl-legacy-provider"
    2. 在启动项目:yarn start
  • 2、方法二:

    使用nvm将node修改为不高于16的版本