Jason's Blog

October 5, 2024

When node's version's been updated but my project needs a old version.

bug1.7 min to read

When node's version has been updated but my project needs a old version.

Preface

Today when i was debugging my project, some problems were found. It was due to the update behaviour that i had done when trying to deploy my vercel project locally. I updated my node version from a old one that i forgot which it was to a new one whose version is v20.17.

Then I found something wrong: my "npm run build" went broken . So did my "npm start". I searched the Internet for solutions then i found them

You can find a Chinese version of this solution which is the blog that i just found.


Temporary way to solve it

In cmd, input "SET NODE_OPTIONS=--openssl-legacy-provider" Then your deployment will adjust the version of environments that you need.


Long term way of solution

Modifying the package.json where

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

Notice

About: SET NODE_OPTIONS=--openssl-legacy-provider, in fact, this method can't be done once and for all. For example, in this case the node's date for the current is December 4, 2022. Openssl3.0 is the latest, the previous version belongs to the legacy version, but with the passage of time,

In the future, openssl 3.0 may also become the legacy version, and then set SET NODE_OPTIONS=--openssl-legacy-provider to inform node.js to use traditional openSSL for execution, then it may run an error.

So for the iterative maintenance of the product, the best thing is to use the old version of node.js, such as version 16, which may be the key to solving the problem.

lol