Webpack报错Error: error:0308010C:digital envelope routines::unsupported处理
在学习组件库流程
打包的时候报错找不到module,后来改了版本又报错
Error: error:0308010C:digital envelope routines::unsupported
报错原因:node17+版本对发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.
解决方案:在网上搜索了很多,有三种解决方案,选了一种最方便的,就是修改配置方案,在build后面加上:set NODE_OPTIONS=--openssl-legacy-provider
"scripts": {
"serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --open",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"lint": "vue-cli-service lint",
"build:js": "set NODE_OPTIONS=--openssl-legacy-provider && webpack --config ./webpack.components.js"
},
记一下我的版本:
"dependencies": {
"core-js": "^3.8.3",
"node": "^20.6.0",
"sass": "^1.68.0",
"vue": "^2.6.14",
"webpack": "^5.44.0",
"webpack-cli": "^5.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"sass-loader": "^13.3.2",
"vue-loader": "^15.10.0",
"vue-template-compiler": "^2.6.14"
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步