NVM
Sometimes, different projects will use different versions of Node. In this case, you need to use NVM to manage node versions for easy development
Windows system
Install the NVM
Download the installation package from github.com/coreybutler… For Windows, download the nVM-setup. zip installation package and install it all the way by default
Img – blog. Csdnimg. Cn / 20210419233…
After installation, find the installation path, some simple configuration, open setting.txt
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
Copy the code
Img – blog. Csdnimg. Cn / 20210419235…
The use of NVM
NVM on // Enable Node.js version management NVM install <version> // Install node.js named version is the version number for example: NVM install 8.12.0 NVM uninstall <version> // Uninstall Node.js Yes command to uninstall the specified node.js, NVM list available // Displays all node.js versions that can be installed. NVM use <version> // Switch to the specified node.js version NVM v // Displays NVM versions. NVM install stable // Installs the latest stable versionCopy the code
MAC system
Install the NVM
/ / in the terminal setup command execution curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bashCopy the code
V0.33.8 is the version number of NVM. After the command runs, exit the terminal and open it again
Success: Then execute NVM to see if it responds. If a stack of code is generated and Node Version Manager is displayed at the bottom, the installation is successful
The following uses 8.9.2 as an example: NVM ls: Displays all versions. NVM install stable: Installs the most stable version NVM install v8.9.2. NVM use v8.9.2: NVM alias default 0.12.7: Uninstall node 8.9.2: NVM use v8.9.2: NVM alias default 0.12.7: Default: Set the default node version to 0.12.7 NVM alias Default: set the default node version to 0.12.7 NVM alias: set the default node version to 0.12.7 NVM alias NPM install -g mz-fis: Install the MZ-fis module to the global directory and run the following command to install the mZ-fis module: / Users / < user name > /. NVM/versions/node/v0.12.7 / lib/mz - fis NVM use 4: switch to version 4.2.2 (support fuzzy queries) NPM install - g react - native - the cli: Install the react - native - cli module to the global directory, install path: / Users / < your username > / NVM/versions/node/v4.2.2 / lib/react - native - cliCopy the code
Installation failure Cause
A, failure problem: on the MAC “curl: (7) Failed to connect to port 443 raw.githubusercontent.com: Connection refused” – installation NVM
1. Go to www.ipaddress.com/
2. Check the corresponding IP address at raw.githubusercontent.com
3. Replace the system host file img – blog. Csdnimg. Cn / 20200627195… 4 write: 199.232.68.133 raw.githubusercontent.com
5. Run the commands in Chapter 1 to reinstall the software.
Problem 2 If command not found: NVM is displayed, the installation fails.
Failure is likely because of the computer inside the lack of a place called the following file, the file is a hidden files and directories in/Users/YourMacUserName /. Following
If your computer does not display hidden files by default, you can use the shortcut command+ Shift +. (there is a dot here.) If you don’t have this file on your computer create a new one, if you do, double click to open it, copy and paste in the code below, and save
Export NVM_DIR = ". $HOME/NVM "# export NVM_DIR =". / Users/username/NVM "[-s" $NVM_DIR/NVM. Sh "] && \. "$NVM_DIR/NVM. Sh # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"Copy the code
Then source.bash_profile
source .bash_profile
Copy the code
After saving, go back to the terminal and execute the installation command again:
The curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bashCopy the code
Remember to exit and restart the terminal after installation