There are two management modes for configuring Node and NPM on a Mac. Both of them rely on other management tools to manage installation, uninstallation, upgrade, and downgrade. Currently, two NVM and N are mainly used

nvm

NVM is currently the most widely used one in Mac and Windows, and its installation and use are relatively simple. The following describes its installation, uninstallation and Node control

1. NVM installation:

The curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bashCopy the code

MacOS10 is bash, but bszh_profile is bszh_profile. M1 is ZSH by default.

2. Node control:

The node installation

nvm install <version>
Copy the code

The node uninstall

nvm uninstall <version>
Copy the code

Node Version Switching

nvm use <version>
Copy the code

Specifies the node version to run

nvm run <version> <target>
Copy the code

View the LTS version of node

nvm ls -remote 
Copy the code

n

N Also controls the node version on the MAC

1. N Installation

sudo npm install -g n 
Copy the code

2. Node control

The node installation

n <version>
Copy the code

The node uninstall

n rm <version>
Copy the code

Node Version Switching

n
Copy the code

Note: After entering the command, the installed version list of Node appears, switch node version by up or down key, select the target version you want to switch and press Enter

View the LTS version of node

n lts
Copy the code