简体   繁体   English

使用NVM安装多个版本的node.js(Ubuntu)

[英]Install multiple version of node.js using NVM (Ubuntu)

如何使用NVM在Ubuntu中安装多个版本的node.js?

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. 在此示例中,我将安装节点v0.4.12。 We first need open new bash session. 我们首先需要打开新的bash会话。 You can also do this by typing bash again. 您也可以通过再次输入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. 如果没有安装所有依赖项,则无法编译/安装node.js。 Then you will need to clean up ~/.nvm 然后您需要清理〜/ .nvm

$ rm -rf ~/.nvm/

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

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 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Install Node.js with Node Version Manager in linux (Ubuntu, linux mint) 在Linux中使用Node Version Manager安装Node.js(Ubuntu,Linux Mint)


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 须藤apt-get install libssl-dev

3. Install nvm using cURL 3.使用cURL安装nvm

curl -o- https://raw.githubusercontent.com/cre ... | curl -o- https://raw.githubusercontent.com/cre ... | bash 重击

4. Check installation work 4.检查安装工作

command -v nvm 命令-v nvm

5. List available node versions 5.列出可用的节点版本

nvm ls-remote nvm ls-remote

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

More Info 更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM