Article Catalog
- I. Completely uninstall the old nodejs
- 1, open the system's control panel, click Uninstall a program, uninstall nodejs
- (1) Open your system's Control Panel and click Uninstall a program under Programs.
- (2) Find, right-click on the drop-down box appears, point uninstallation
- (3) Confirm the uninstallation pop-up window, click Yes and wait for the uninstallation to complete.
- 2. Delete the installation directory of node
- 3. Find out if the .npmrc file exists, and delete it if it does.
- 4. Check the following files one by one to see if they exist, and delete them if they do.
- 5, open the system settings, check the system environment variables, node-related configuration are deleted!
- 6. Check if the uninstallation is successful
- 7, finally, it is recommended to restart the computer
- II. Installation of nvm
- 1. Download NVM
- 2、Double-click the downloaded file to start installation
- 3, select I accept, and then click next
- 4, select the NVM installation path, the path name should not have spaces, and then click next
- 5, the installation path, and then click next
- 6. Click Install
- 7, click Finish, complete the installation
- Third, nvm modify the mirror source
- Fourth, nvm common commands
- V. nvm configuration environment variables
- VI. Installation of nodejs and environment variable configuration
- 1. Install node via nvm
- 2, node environment variable configuration
- (1) Configure globally installed module paths and cache paths
- (2) Setting user variables
- (3) Setting system variables
- 3. Testing
- 4, set Taobao's mirror and view
- VII. Global installation of cnpm
- VIII. Global installation of yarn
- IX. The author's installation directory structure
Attention:
1. Before installing nvm you need toUninstall the previous nodejsand also remove the previous environment variable configurations, otherwise you will get some strange problems!
2. nvm installation pathNo Chinese characters or spacesOtherwise, switching the node version later in cmd will result in a garbled code
I. Completely uninstall the old nodejs
reference articleNode uninstallation step by step
1, open the system's control panel, click Uninstall a program, uninstall nodejs
(1) Open your system's Control Panel and click Uninstall a program under Programs.
(2) Find, right-click on the drop-down box appears, point uninstallation
(3) Confirm the uninstallation pop-up window, click Yes and wait for the uninstallation to complete.
2. Delete the installation directory of node
The installation directory defaults toC:\Program Files\nodejs
My installer chose to install mine in theD:\Program Files\nodejs
。
Check if there are node files under this pathIf you uninstall node from the control panel, the node files will be deleted automatically.Delete it manually if it's still there, ignore it if you don't have it.
3. Find out if the .npmrc file exists, and delete it if it does.
.npmrc
Defaults to theC:\User\User Name
。
.node_repl_history
Delete it if it exists as well, ignore it if it doesn't.
4. Check the following files one by one to see if they exist, and delete them if they do.
C:\Program Files (x86)\Nodejs
C:\Program Files\Nodejs
C:\Users\User Name\AppData\Roaming\npm
C:\Users\User Name\AppData\Roaming\npm-cache
C:\Users\Username\AppData\Local\npm-cache
5, open the system settings, check the system environment variables, node-related configuration are deleted!
- Generally, the system will automatically delete the node environment variables, you can not care about this step
- The way the environment variable is opened:
My Computer-> Properties-> Advanced System Settings-> Environment Variables->.
- deleteuser variablecap (a poem)system variable(used form a nominal expression)
NODE_PATH
up toPath
The relevant node in theDon't take the wholepath
deleteIf you click Edit, just delete the node-related ones; if you make a mistake, click theabolishClose the pop-up window will not be saved successfully, if the hand accidentally deleted, but also clicked on therecognizebutton, then there is nothing the author can do) -
Confirmation of deletionAfter that, click on therecognizeClose, otherwise there may be a deletion failure problem
6. Check if the uninstallation is successful
From the keyboard, presswin + R
Inputcmd
, and then hit enter and type in the command linenode -v
npm -v
The following figure indicates that the uninstallation was successful.
,
7, finally, it is recommended to restart the computer
II. Installation of nvm
reference articlenvm-Download, Installation, Use (Updated 2023/07/12) Install nvm and use nvm to install nodejs and configure environment variables.
1. Download NVM
- Address:/coreybutler/nvm-windows/releases
- strike (on the keyboard)
Download
2、Double-click the downloaded file to start installation
3, select I accept, and then click next
4, select the NVM installation path, the path name should not have spaces, and then click next
5, the installation path, and then click next
6. Click Install
7, click Finish, complete the installation
Third, nvm modify the mirror source
reference articlenvm download, nvm installation, nvm modification mirror source, nvm use.
-
win + R
Inputcmd
After Enter, at the command line, typenvm root
command, which canCheck the root path of the nvm installationIt's in that folder.
- In the file manager address barimportation
root
addressFindfile and open it
- Copy and paste the following code as shown. Save to complete the nvm source modification.
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
Fourth, nvm common commands
reference articlenvm download, nvm installation, nvm modification mirror source, nvm use.
-
nvm install <version>
: Install the specified version of . -
nvm use <version>
: Switch to the specified version of . -
nvm ls
: Lists all installed versions. -
nvm alias <name> <version>
: Create an alias for the specified version. -
nvm run <version> <script>
: Runs the script under the specified version. -
nvm current
: Displays the version currently in use. -
nvm uninstall <version>
: Uninstall the specified version of .
V. nvm configuration environment variables
reference articleInstall nvm and use nvm to install nodejs and configure environment variables.
- The way the environment variable is opened:
My Computer-> Properties-> Advanced System Settings-> Environment Variables->.
- Verify consistency with the following configuration (default nvm will be generated automatically after a successful nvm installation)
-
win + R
Inputcmd
After Enter, at the command line, typenvm -v
command, which returns the version number, proving that the configuration was successful.
VI. Installation of nodejs and environment variable configuration
reference articleInstall nvm and use nvm to install nodejs and configure environment variables.
1. Install node via nvm
- Check out the latest batch of versions (version numbers: even numbers are absolutely stable versions, base numbers are not necessarily stable versions)
nvm list available
- Installs the specified version:
nvm install 10.23.0
- View all versions installed:
nvm list
maybenvm ls
- Enter or switch versions:
nvm use 18.15.0
- After successful installation, the corresponding folder will be formed, as shown in the following figure
- Check if the installation was successful:
node -v
Check out the version of node,npm -v
Check the version of npm
2, node environment variable configuration
(1) Configure globally installed module paths and cache paths
- First in the NVM installation directoryCreate two new folders
node_global
cap (a poem)node_cache
- After creating the two folders, enter the following commands in the cmd window (the two paths are the paths to the two folders)
npm config set prefix "D:\Programs\nvm\node_global"
npm config set cache "D:\Programs\nvm\node_cache"
(2) Setting user variables
- The path variable in [User Variables].
%NVM_HOME%
cap (a poem)%NVM_SYMLINK%
Theoretically, it is automatically generated after nvm is successfully installed. If not, create a new one in. - If there is
C:\Users\User Name\AppData\Roaming\npm
, then change it toD:\Programs\nvm\node_global
(where you just created the node_global folder), if you don't have it, create it yourself.D:\Programs\nvm\node_global
In short, it's guaranteed to have what's in the following pictures
(3) Setting system variables
- The path variable is set as in the user variable.
- New Environment Variables
NODE_PATH
The value isD:\Programs\nvm\node_global\node_modules
whichD:\Programs\nvm\node_global\node_modules
is the global module installation path folder created above
3. Testing
- Install the most commonly used express modules globally for testing
npm install express -g
- Upon completion you will get a
express
documents
4, set Taobao's mirror and view
npm config set registry https:///
npm config get registry
VII. Global installation of cnpm
reference articleManaging npm and cnpm and yarn commands in node based on nvm.
- cnpm itself is domestic, so there's no need to configure mirrors.
- cnpm installation [the example in the picture is the old address, not updated, copy the code below]
npm install -g cnpm --registry=https:///
maybe
npm install -g cnpm
- View cnpm version
cnpm -v
npm list cnpm -g
VIII. Global installation of yarn
reference articleManaging npm and cnpm and yarn commands in node based on nvm.
- Yarn Installation
npm install yarn -g
- Set up Taobao mirrors and view
// Viewing Mirrors
yarn config get registry
// Modify the image
yarn config set registry https://registry.npmmirror.com