npm run serve出现错误 error:0308010C:digital envelope routines::unsupported

因为新换了电脑,重新安装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 成功 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你在运行`npm run dev`时,出现错误`Error: error:0308010C:digital envelope routines::unsupported`。这个错误通常是由于你的Node版本不兼容所导致的。你可以尝试以下几个解决方法来解决这个问题: 1. 更新Node版本:首先,确保你使用的是最新版本的Node。你可以前往Node.js官方网站下载并安装最新版本的Node。然后,重新运行`npm run dev`,看看问题是否得到解决。 2. 清除缓存并重新安装依赖:有时候,缓存中的一些问题可能会导致出现错误。你可以尝试清除npm缓存并重新安装依赖项。可以通过运行以下命令来清除npm缓存: ``` npm cache clean --force ``` 然后,删除`node_modules`文件夹,并重新安装依赖项: ``` npm install ``` 最后,再次运行`npm run dev`,查看问题是否解决。 3. 更新依赖版本:有时,某些依赖包的旧版本可能与当前的Node版本不兼容。你可以尝试更新相关的依赖版本来解决此问题。可以在`package.json`文件中查找相关的依赖项,并将其版本号更新为较新的版本。然后,运行`npm install`来安装更新后的依赖项。 注意:在更新依赖版本之前,请确保你已备份了项目,并且了解更新依赖版本可能会引入其他问题。 总之,通过更新Node版本、清除缓存并重新安装依赖、以及更新依赖版本,你应该能够解决`npm run dev`时出现的`Error: error:0308010C:digital envelope routines::unsupported`错误。希望这些解决方法对你有帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值