异常:
node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
原因:
使用Node v18启动Node v14创建的项目出现如上异常
解决:
在package.json中调整scripts,如下
原:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
调整:
"scripts": {
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"lint": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"
},
注意:
调整后,node v14会报错
其他解决方法:
设置环境变量,自行百度
Node v18项目兼容性问题:openssl-legacy-provider解决方案

本文探讨了在Node.js 18环境中运行由Node v14构建项目时遇到的内部crypto错误,重点在于如何通过调整`package.json`中的scripts和设置环境变量--openssl-legacy-provider来解决此问题。同时提供了其他可能的解决方案和注意事项。
2449

被折叠的 条评论
为什么被折叠?



