1. Install n
terminal run npm install n -g
command
If you use npm install n -g
it directly to report an error, you must add one in front of it sudo
to run with an administrator role.
Use after installation n
or n --version
view
Two, common commands
Install or use a version: n node-version
e.g.sudo n 14,18.3
When using the command sudo n 14,18.3
:
When sudo n 14,18.3
the version is not installed, install this version.
If sudo n 14,18.3
the version is already installed, switch the node version.
View all installed node versions:n
You can enter n
the command in the terminal to view all installed node versions.
In the version display interface, you can use the up and down arrows to select the node version you want to use, and then press Enter to select.
Press q
or control + C
to exit the node version list:
Install the latest node
version: n latest
Install the latest stable version: n stable
Install the latest long-term maintenance version: n lts
Delete a version n rm <version>
Delete all other versions except the current version:n prune