Solve the problem of ruoyi framework front-end startup error due to the openssl library version being too low

At first, I thought it was a problem with the corresponding versions of node and npm. After installing the version comparison table provided by the nodejs official website, I still reported this error when downgrading npm and changing the version of node to the corresponding version. I continued to search and found that it might be a problem with the openssl library version.

Error message: This error occurs in about 10% of cases

10% building 2/5 modules 3 active ...dmin-better\node_modules\eslint-loader\index.js??ref--14-0!D:\home\project\demo\vue-admin-better\src\main.jsnode:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);

Problems occur because the openssl library version is too low

Solution

1. Edit system environment variables

Add the following system environment variables

NODE_OPTIONS

--openssl-legacy-provider

 2. Modify the configuration before starting

Modify package.json and add it before building and running

set NODE_OPTIONS=–openssl-legacy-provider

The script is modified as follows

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

Guess you like

Origin blog.csdn.net/m0_54250110/article/details/129773817