問題描述
使用 npm run dev
或者 yarn run dev
時(shí)報(bào)錯(cuò):error:0308010C:digital envelope routines::unsupported
nodejs 版本為 18.12.1
解決方案
Google 了一下發(fā)現(xiàn)是 Node JS 17 的 BUG,相關(guān) ISSUE 也給出了解決辦法,就是修改package.json,在相關(guān)構(gòu)建命令之前加入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 環(huán)境,請加入 export NODE_OPTIONS=--openssl-legacy-provider