The relationship between node version and npm version and how to install the specified version of npm package

1.node version and npm version

Normally, if a computer is installed with node, it will automatically install the npm package corresponding to the node version, but sometimes when you get a new project, it is easy to encounter that the node/npm version is too high or too low and the dependencies of the project cannot be downloaded Problem with installation.

On the official website , you can find the relationship between a specified version of node and npm

At this time, you need to lower/raise your own node version. If it is uninstalled and reinstalled, the npm and node versions must correspond. But if we use a node version control tool like nvm or other situations that cause the node version to not correspond to the npm version, blindly increasing or lowering the node may cause a mismatch between npm and node versions, and the front-end dependencies cannot be installed correctly . At this time, we need to manually increase/decrease the version of npm.

2. How to install the specified version of the npm package

After finding the npm package corresponding to a certain node version on the official website .
insert image description here
You can use the following command to install the specified version of the npm package:

cnpm install [email protected] -g

Guess you like

Origin blog.csdn.net/vet_then_what/article/details/127421024