因为新换了电脑,重新安装vs code和 nodejs 跑前端项目,npm run install之后,vs code命令行出现错误:error: error:0308010C:digital envelope routines::unsupported

10% building 2/4 modules 2 active ...node_modules\webpack\hot\dev-server.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:\workstation\adautotest_workstation\adautotest_web\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\workstation\adautotest_workstation\adautotest_web\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\workstation\adautotest_workstation\adautotest_web\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\workstation\adautotest_workstation\adautotest_web\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\workstation\adautotest_workstation\adautotest_web\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (D:\workstation\adautotest_workstation\adautotest_web\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (D:\workstation\adautotest_workstation\adautotest_web\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at D:\workstation\adautotest_workstation\adautotest_web\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active ...workstation\adautotest_web\src\main.js n
ode:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);

网上查了,可能是nodejs版本过高导致的错误:

解决办法:

在命令行跑下列命令:

set NODE_OPTIONS=--openssl-legacy-provider

再次运行:npm run serve 成功 

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐