报错:Error: error:0308010C:digital envelope routines::unsupported

报错:Error: error:0308010C:digital envelope routines::unsupported

运行VUE项目(npm run dev )时候跳出的报错,nodeJs V17版本后会出现这样的问题,解决办法就是降级或者使用下面方法

解决方案:
方案1:进入项目后打开终端(CMD),直接输入

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

Windows:
set NODE_OPTIONS=--openssl-legacy-provider

或者直接在VUE配置文件中修改(package.json) 增加
修改后

 "scripts": {
    "dev": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service serve",
    "build:prod": "vue-cli-service build",
    "build:stage": "vue-cli-service build --mode staging",
    "preview": "node build/index.js --preview",
    "lint": "eslint --ext .js,.vue src"
  },

修改前

 "scripts": {
    "dev": " vue-cli-service serve",
    "build:prod": "vue-cli-service build",
    "build:stage": "vue-cli-service build --mode staging",
    "preview": "node build/index.js --preview",
    "lint": "eslint --ext .js,.vue src"
  },

亲测有效。

此处评论已关闭