前端项目npm run serve报错

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:company_projectmap-edit2fontnode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:471:10)
    at D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:503:5
    at D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:358:12
    at D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at iterateNormalLoaders (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:221:10)
    at D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:236:3
    at runSyncOrAsync (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:130:11)
    at iterateNormalLoaders (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:232:2)
    at Array.<anonymous&gt; (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:company_projectmap-edit2fontnode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:company_projectmap-edit2fontnode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at module.exports (D:company_projectmap-edit2fontnode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:471:10)
    at D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:503:5
    at D:company_projectmap-edit2fontnode_moduleswebpacklibNormalModule.js:358:12
    at D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at Array.<anonymous&gt; (D:company_projectmap-edit2fontnode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:company_projectmap-edit2fontnode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:company_projectmap-edit2fontnode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
    at D:company_projectmap-edit2fontnode_modulesgraceful-fsgraceful-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 v18.12.1

问题原因

查了下原因,主要是 nodeJs V17 版本发布了 OpenSSL3.0 对算法和秘钥大小增加了更为严格限制,nodeJs v17 之前版本影响,但 V17 和之后版本出现这个错误。 我的node版本是v18.12.1

解决方式(仅 windows):

package.jsonscripts 中新增 SET NODE_OPTIONS=–openssllegacyprovider

添加前:

scripts”: {

dev“: “vuecliservice serve“,

build:prod“: “vuecliservice build

},

添加

scripts”: {

dev“: “SET NODE_OPTIONS=–openssllegacyprovider &amp;&amp; vuecliservice serve“,

“build:prod“: “SET NODE_OPTIONS=–openssllegacyprovider &amp;& vuecliservice build”

},

原文地址:https://blog.csdn.net/Alan_Walker1/article/details/129682253

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_46096.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注