How to change the default version of node for nvm
Xiaobian to share with you how to change the node default version of nvm, I hope you have something to gain after reading this article, let's discuss it together!
How to change the default version of node by nvm: 1. Open the terminal command window;2. Set the default version of nodejs by executing the command "nvm alias default v4.3.0".
Operating environment of this article: macOS 10.15 system, nvm v0.34.0 version, macbook pro 2020 computer.
nvm set nodejs default version
Windows version management software is nodist
The node version management of mac system is based on nvm
Every time you restart vscode, the default version nvm ls sees reverts to v5.5.
Use the following command to change the default version: nvm alias default v4.3.0 so you don't have to switch versions every time
NVM installation:
Click Jump (github address of nvm project), find the place where install script is located, then copy it, paste it in terminal and run it.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
According to the terminal prompt
=> 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 script given, and 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 to display the version number, i.e. successful installation!
Common commands for installing node, npm(cnpm), and nvm on Mac:
Nvm common command
● nvm install stable Install the latest stable version node
● nvm install Install the specified version, such as: install v4.4.0, nvm install v4.4.0
● nvm uninstall removes the specified version installed, syntax similar to install
● nvm use Switch to use the specified version node
● nvm ls lists all installed versions
● nvm alias default such as: nvm alias default v11.1.0
After reading this article, I believe you have a certain understanding of "how to change the node default version of nvm". If you want to know more about it, welcome to pay attention to the industry information channel. Thank you for reading!