Nvm method to change the default version of node: 1. Open the terminal command window; 2. Set the default version of nodejs by executing the "nvm alias default v4.3.0" command.
The operating environment of this article: macOS10.15 system, nvm v0.34.0 version, macbook pro 2020 computer.
nvm Set the default version of nodejs
The version management software of the windows system is nodist
The node version management software of the mac system is based on nvm
Every time you restart the vscode software, the default version seen by nvm ls will be restored to v5.5
Use the following command to change the default version: nvm alias default v4.3.0 This way you don’t have to switch every time Version
nvm installation:
Click to jump (the github address of the nvm project), find the install script, then copy it, paste it in the terminal and run it.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
According to the terminal prompts
=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/. zshrc, and ~/.profile.
=> Create one of them and run this script again
1. So use vim to create a ~/.bash_profile file
JasonLamdeMacBook-Pro:~ jasonlam$ vim ~/.bash_profile
2. After switching vim to insert state, write the given script, then: wq exit
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
:wq
Restart the terminal and enter nvm --version The version number will be displayed and the installation is successful! ! !
3. Use nvm to install node, npm (cnpm) and nvm common commands on Mac:
● nvm install stable Install the latest stable version of node
● nvm install
● nvm uninstall
● nvm use
● nvm ls List all installed versions
● nvm alias default
Recommended learning: "node.js video tutorial"
The above is the detailed content of How to change the default version of node in nvm. For more information, please follow other related articles on the PHP Chinese website!