您的位置:首页 > 教育 > 培训 > node编译打包Error: error:0308010C:digital envelope routines::unsupported

node编译打包Error: error:0308010C:digital envelope routines::unsupported

2024/10/6 21:26:40 来源:https://blog.csdn.net/LG_15011399296/article/details/140124566  浏览:    关键词:node编译打包Error: error:0308010C:digital envelope routines::unsupported

问题描述:
        报错:Error: error:0308010C:digital envelope routines::unsupported

报错原因:

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

02-七月-2024 11:37:14	/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
02-七月-2024 11:37:14	yarn run v1.22.19
02-七月-2024 11:37:15	$ vuepress build docs
02-七月-2024 11:37:15	/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
02-七月-2024 11:37:15	/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
02-七月-2024 11:37:15	wait Extracting site metadata...
02-七月-2024 11:37:15	tip Apply theme local ...
02-七月-2024 11:37:15	tip Apply plugin container (i.e. "vuepress-plugin-container") ...
02-七月-2024 11:37:15	tip Apply plugin @vuepress/last-updated (i.e. "@vuepress/plugin-last-updated") ...
02-七月-2024 11:37:15	tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
02-七月-2024 11:37:15	tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
02-七月-2024 11:37:15	tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
02-七月-2024 11:37:15	tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
02-七月-2024 11:37:16	[info] [webpackbar] Compiling Client
02-七月-2024 11:37:16	[info] [webpackbar] Compiling Server
02-七月-2024 11:37:18	Language does not exist: curl������������
02-七月-2024 11:37:18	Language does not exist: curl������������
02-七月-2024 11:37:18	Language does not exist: curl������������
02-七月-2024 11:37:31	[success] [webpackbar] Client: Compiled with some errors in 14.51s
02-七月-2024 11:37:31	[success] [webpackbar] Server: Compiled successfully in 14.62s
02-七月-2024 11:37:31	(undefined) assets/js/styles.7ce2b3ab.js from Terser
02-七月-2024 11:37:31	Error: error:0308010C:digital envelope routines::unsupported
02-七月-2024 11:37:31	    at new Hash (node:internal/crypto/hash:80:19)
02-七月-2024 11:37:31	    at Object.createHash (node:crypto:139:10)

解决方案: 
方案1:打开IDEA 终端,直接输入

Linux & Mac OS:
export NODE_OPTIONS=--openssl-legacy-providerWindows:
set NODE_OPTIONS=--openssl-legacy-provider


方案2:打开IDEA 终端,直接输入(问题解决)

$env:NODE_OPTIONS="--openssl-legacy-provider"

 方案3:卸载当前版本,安装合适的版本(node.js)

方案4:

解决方式(仅限 windows):

在项目中 package.json 的 scripts 中新增 SET NODE_OPTIONS=--openssl-legacy-provider

添加前:

"scripts": {
"dev": "vue-cli-service serve","build:prod": "vue-cli-service build"},


添加后:

"scripts": {
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve","build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"},

本人是采用第四种方案解决的,大家可以试试,希望可以帮到大家。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com