Using NVM to manage the Nodejs version

Source: Internet
Author: User

NVM is the node management tool under Mac, a bit like the RVM that manages Ruby, and if you need to manage node under Windows, the official recommendation is to use NVMW or nvm-windows. NVM is primarily used to switch between different nodejs versions so that when node is out of the new version, some new features can be used

NVM installation
git clone https://github.com/creationix/nvm.git ~/.NVM

Then open ~/.bashrc ,在其中添加:

SOURCE ~/.NVM/NVM. SH

Re-ssh and login to run later

Install (node's version number)

This will be installed in the home directory

Install Nodejs One, uninstall the NODE/NPM that have been installed to the global

If the node installation package was previously downloaded on the website, it will be automatically installed in the global directory after it is run, where

The node command is in the/usr/local/bin/node, NPM command in the global node_modules directory, the specific path is/USR/LOCAL/LIB/NODE_MODULES/NPM

After installing NVM, it is a good idea to remove the node and global node modules that are installed:

Npmls-G--depth=0#查看已经安装在全局的模块 in order to remove these global modules and then re-install the global installation according to different node versionssudo RM-rf/usr/local/lib/node_modules #删除全局 node_modules directorysudo RM/usr/local/bin/node #删除 nodecd/usr/local/bin &&ls-L |grep ".. /lib/node_modules/"|awk '{print $9}'|Xargs RM#删除全局 Node Module Registration of the soft chain
Second, the installation switch versions NODE/NPM
NvmInstallStable #安装最新稳定版 node, and now it's5.0.0NVMInstall 4.2.2#安装4.2.2version NVMInstall 0.12.7#安装0.12.7version # Special NOTE: The following module installation is for illustrative purposes only, not required to install the module NVM use0#切换至0.12.7version NPMInstall-G Mz-fis #安装 Mz-fis module to the global directory, the path to complete installation is/users/< your user name >/.nvm/versions/node/v0.12.7/lib/mz-FISNVM Use4#切换至4.2.2version NPMInstall-G react-native-cli #安装 REACT-NATIVE-CLI module to the global directory, the path to complete installation is/users/< your user name >/.nvm/versions/node/v4.2.2/lib/react-native-CLINVM alias Default0.12.7#设置默认 node version is0.12.7
Third, use the node version of the. nvmrc File Configuration item

If your default node version (set by the NVM alias command) differs from the version required by your project, you can create a. nvmrc file in the project root directory or any of its parent directories, specifying the node version number used in the file, for example:

CD < project root >  #进入项目根目录 echo4 >-v #查看 node switch to the corresponding version

Using NVM to manage the Nodejs version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.