Node opensslErrorStack error solution records

I downloaded an old project from the Git warehouse, and npm installthere is no problem after installation. When I use it, I npm run devencounter OpenSSL-related errors, such asopensslErrorStack: ['error:03000086:digital envelope routines::initialization error']

I found relevant information on the Internet, and then solved it smoothly. I will share the record with you.

problem causes:

This error is usually related to a compatibility issue between the Node.js version and the OpenSSL version. Certain Node.js versions may not be compatible with certain versions of OpenSSL, causing problems with encryption or security-related functionality.

solution:

First, make sure your Node.js and OpenSSL versions. You can check the version with the following command:

node -v
openssl version

If you find compatibility issues between your Node.js version and your OpenSSL version, you can try the following solutions:

In the section of your project's package.jsonfile scripts, add a new script like dev:

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

Or on Linux or macOS systems, use the following command:

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

where devis your actual startup script name.

Save package.jsonthe file.

In a terminal or command prompt, navigate to the project directory.

Run the following command to ensure all dependencies are installed:

npm install

Run the following command to start your application:

npm start

Certain OpenSSL errors may be resolved by adding NODE_OPTIONS=--openssl-legacy-providerto the startup script, which essentially sets an environment variable to use an older version of the OpenSSL provider.

But this is only a temporary solution, maybe with the update of Node.js and OpenSSL, the problem may be fixed.

Guess you like

Origin blog.csdn.net/u013431141/article/details/132495025