<>问题描述

使用 npm run dev 或者 yarn run dev 时报错:error:0308010C:digital envelope
routines::unsupported

nodejs 版本为 18.12.1

<>解决方案

Google 了一下发现是 Node JS 17 的 BUG,相关 ISSUE 也给出了解决办法,就是修改package.json,在相关构建命令之前加入
set NODE_OPTIONS=--openssl-legacy-provider
"scripts": { "dev": "set NODE_OPTIONS=--openssl-legacy-provider & node
build/dev-server.js", "serve": "set NODE_OPTIONS=--openssl-legacy-provider &
vue-cli-service serve", "build": "set NODE_OPTIONS=--openssl-legacy-provider &
vue-cli-service build", "build:report": "set
NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build --report",
例如,如果你使用的命令是npm run dev,那么就在 scripts 命令下的 dev 命令前面加

如果是 Linux 或者 WSL 环境,请加入 export NODE_OPTIONS=--openssl-legacy-provider

<>补充

你也可以把 NodeJS 的版本降到12,也不会出现这个问题

技术
今日推荐
PPT
阅读数 93
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信