Error: error:0308010C:digital envelope routines::unsupported when nodejs initializes and runs the project

I originally wanted to initialize and run ruoyi's front-end vue project, but I didn't expect to report an error when running

Reason: because the nodejs I installed is V18. Updated OpenSSL after node17

Because of the recently released OpenSSL3.0 in the node.js V17 version, OpenSSL3.0 has added strict restrictions on the allowed algorithms and key sizes, which may have some impact on the ecosystem. Therefore, the previous project will report an error after upgrading the nodejs version

#windows系统
set NODE_OPTIONS=--openssl-legacy-provider

#macOS 系统
export NODE_OPTIONS=--openssl-legacy-provider

NOTE: The downside is that you have to declare it once per run

Or modify package.json, add set NODE_OPTIONS=– openssl -legacy-provider before the relevant build command

  "scripts": {
    "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
    "build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",

},

  • Permanent solution, lower node version

 Run the project again successfully. Sprinkle flowers! Call it a day!

Guess you like

Origin blog.csdn.net/leonnew/article/details/127557013