使用 NVM (Ubuntu) 安装多个版本的 node.js
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8108609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install multiple version of node.js using NVM (Ubuntu)
提问by Alfred
回答by Alfred
prior knowledge
先验知识
How to use the terminal. You can for example use gnome-terminal.
如何使用终端。例如,您可以使用gnome-terminal.
Install dependencies
安装依赖
sudo apt-get install build-essential libssl-dev curl git-core
Install NVM
安装 NVM
Below we will install NVM.
下面我们将安装 NVM。
Download nvm
下载 nvm
git clone git://github.com/creationix/nvm.git ~/.nvm
To activate nvm, you need to source it from your bash shell
要激活 nvm,您需要从 bash shell 获取它
echo "\n. ~/.nvm/nvm.sh" >> .bashrc
Install version of node.js
安装 node.js 版本
In this example I am going to install node v0.4.12. We first need open new bash session. You can also do this by typing bashagain.
在这个例子中,我将安装 node v0.4.12。我们首先需要打开新的 bash 会话。您也可以通过bash再次键入来执行此操作。
$ bash
$ nvm install v0.4.12 #This takes a while.
To make the latest v0.4 branch default you do
要使最新的 v0.4 分支默认,您可以
$ nvm alias default 0.4
Troubleshooting
故障排除
When you don't have all dependencies installed you can not compile/install node.js. Then you will need to clean up ~/.nvm
当您没有安装所有依赖项时,您将无法编译/安装 node.js。然后你需要清理 ~/.nvm
$ rm -rf ~/.nvm/
回答by Erel Segal-Halevi
回答by thouliha
The top answer is out of date. Now, just follow the guide on the github to install :
最佳答案已过时。现在,只需按照github上的指南进行安装:
https://github.com/creationix/nvm#installation
https://github.com/creationix/nvm#installation
For linux machines, its as simple as :
对于 linux 机器,它很简单:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v*/install.sh | bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v*/install.sh | bash
Replace v*with the latest version from https://github.com/creationix/nvm/releases.
替换v*为https://github.com/creationix/nvm/releases 中的最新版本。
For example:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
例如:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
回答by Asbar Ali
Install Node.js with Node Version Manager in linux (Ubuntu, linux mint)
在 linux (Ubuntu, linux mint) 中使用 Node Version Manager 安装 Node.js
1. Build essential package
1. 构建必备包
sudo apt-get install build-essential checkinstall
sudo apt-get install build-essential checkinstall
2. Get libssl-dev
2. 获取 libssl-dev
sudo apt-get install libssl-dev
sudo apt-get install libssl-dev
3. Install nvm using cURL
3.使用cURL安装nvm
curl -o- https://raw.githubusercontent.com/cre... | bash
curl -o- https://raw.githubusercontent.com/cre... | 猛击
4. Check installation work
4.检查安装工作
command -v nvm
命令 -v nvm
5. List available node versions
5. 列出可用的节点版本
nvm ls-remote
nvm ls-远程
6. download, compile and install node
6.下载、编译和安装节点
nvm install 6.14.4
nvm 安装 6.14.4
7. Tell nvm which version to use
7.告诉nvm使用哪个版本
nvm use 6.14.4
nvm 使用 6.14.4
8. Set default node version
8. 设置默认节点版本
nvm alias default node 6.14.4
nvm 别名默认节点 6.14.4

