Description of Requirement
In our daily work, we often encounter dependencies of different projects that require different node versions to run. At this time, we need to switch the node version~~
How to switch
Use node.js's multi-version manager n to solve the problem
View all versions of node
npm view node versions
Check the current node version
node -v
Install n module:
sudo npm install -g n
Upgrade to stable version
sudo n stable
XXXXXX ~ % sudo n stable
Password:
installing : node-v18.18.0
mkdir : /usr/local/n/versions/node/18.18.0
fetch : https://nodejs.org/dist/v18.18.0/node-v18.18.0-darwin-x64.tar.xz
copying : node/18.18.0
installed : v18.18.0
XXXXXX ~ % node -v
v18.18.0
XXXXXX ~ %
Switch or upgrade to a certain version
sudo n xx.x
Common commands
Clear node.js cache
sudo npm cache clean -f
Upgrade to the latest version
sudo n latest
Install n module
sudo npm install -g n
View all versions of node
npm view node versions
Upgrade to specific version
sudo n xx.xx
Check the currently installed version number
node -v
Check which versions of node are currently installed
n
That’s all for today~
- Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝSee you tomorrow~~
- Everyone, please be happy every day
Everyone is welcome to point out areas that need correction in the article~
There is no end to learning and win-win cooperation