nvm (mac os x)
First, you’ll need Homebrew.
install
Start by :
brew update
brew install nvm
mkdir ~/.nvm
nano ~/.bash_profile
In your .bash_profile file (you may be using an other file, according to your shell), add the following :
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
Back to your shell, activate nvm and check it (if you have other shells opened and you want to keep them, do the same) :
source ~/.bash_profile
echo $NVM_DIR
Now, you can install node :
nvm install 0.12
From now on, you’re using the v0.12.x of node on this shell, you can install your global dependencies such as grunt-cli (they will be tied up to this version of node).
You’ll have to npm install -g
your global dependencies for each version.
Switch of node version with nvm use 0.12
(more infos here).
To have a node activated by default (not to have to nvm use
on each new shell), run this (stable being the id of the version):nvm alias default stable
Now, you can run multiple versions of node on your computer.
Usage
start a node shell
node
to Exit
ctrl + d
To download, compile, and install the latest release of node, do this(the latest version of node is 7.9 for 04/2017):
nvm install node
And then in any new shell just use the installed version:
nvm use node
Or you can just run it:
nvm run node --version
You can also get the path to the executable to where it was installed:
nvm which 7.9
node
: this installs the latest version of node
.stable
: this alias is deprecated, and only truly applies to node
v0.12
and earlier. Currently, this is an alias for node
.
Listing versions
If you want to see what versions are installed:
nvm ls
If you want to see what versions are available to install:
nvm ls-remote
install Multiple Versions of Node.js
One of the most important parts of nvm is, of course, installing different versions of Node.js. For this, nvm provides the nvm install
command. You can install specific versions by running this command followed by the version you want. For example:
nvm install 6.10.2 //(Latest LTS: Boron)
By running the above in a terminal, nvm will install Node.js version 6.10.2. nvm follows SemVer, so if you want to install, for example, the latest 6.10 patch, you can do it by running:
nvm install 6.10
source
http://dev.topheman.com/install-nvm-with-homebrew-to-use-multiple-versions-of-node-and-iojs-easily/
https://github.com/creationix/nvm/blob/master/README.markdown
https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
上一篇: 老鸟们,看看我的代码,为什么取不到URL里的内容?
下一篇: 怎样在IE6里正常显示PNG-24,上网找了几个方法都试了,但是会整个图片都消失了,什么情况?_html/css_WEB-ITnose
推荐阅读
-
Mac OS X terminal
-
[Mac] OS X Shell
-
nvm (mac os x)
-
yosemite 10.10.3 beta4 下载地址 os x10.10.3beta4官方下载
-
Mac OS X下go的安装,使用,删除
-
苹果OS X Yosemite 10.10.4第二个测试版发布
-
Mac OS下配置PHP+MySql环境,osphp+mysql
-
推荐一款MAC OS X 下php集成开发环境mamp,macmamp
-
mac机上搭建php56/nginx 1.8.x/thinkphp 3.2.x/gearman扩展/seaslog扩展/redis扩展环境 - 菩提树下的杨过
-
轻松掌握在 Mac OS X中安装MySQL_MySQL