Home > Web Front-end > JS Tutorial > How to change the default version of node in nvm

How to change the default version of node in nvm

藏色散人
Release: 2021-12-10 11:27:15
Original
12445 people have browsed it

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.

How to change the default version of node in nvm

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
Copy after login

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 common commands

● nvm install stable Install the latest stable version of node

● nvm install Install the specified version, such as: install v4.4.0, nvm install v4.4.0

● nvm uninstall Delete the installed specified version, the syntax is similar to install

● nvm use Switch to use the specified version node

● nvm ls List all installed versions

● nvm alias default For example: nvm alias default v11.1.0

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template