node.js 在 ubuntu 14.04 中安装最新的 nodejs 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34974535/
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 latest nodejs version in ubuntu 14.04
提问by Aamu
This is the way I installed nodejsin ubuntu 14.04 LTS:
这是我在 ubuntu 14.04 LTS 中安装nodejs的方式:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
When I checked the node version with this:
当我用这个检查节点版本时:
node -v
I get this
我明白了
v0.10.37
But the latest version is 4.2.6 and 5.5.0. How can I get the latest or update version?
但是最新的版本是 4.2.6 和 5.5.0。如何获取最新或更新版本?
回答by war1oc
sudo apt-get install curl
For Node.js v4
对于 Node.js v4
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
For Node.js v5:
对于 Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v6:
Node.js v6:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js v7:
Node.js v7:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
Node.js 8:
节点.js 8:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
回答by loretoparisi
On Ubuntu 14.04.5 LTSthe easier way is
在Ubuntu 14.04.5 LTS更简单的方法是
1 Install npm:
1 安装 npm:
sudo apt-get install npm
sudo apt-get install npm
- Install
n
- 安装
n
sudo npm install n -g
sudo npm install n -g
- Get latest version of node
- 获取最新版本的节点
sudo n latest
sudo n latest
If you prefer to install a specific version of `node you can
如果您更喜欢安装特定版本的`node,您可以
2.1 List available node versions
2.1 列出可用节点版本
n ls
n ls
2.2 and the install a specific version
2.2 并安装特定版本
sudo n 4.5.0
sudo n 4.5.0
回答by Hari Krishnan
There is an issue with node and npm update in Ubuntu14.04 LTS 64 bit OS. Since Google Chrome repository no longer provides 32-bit packages, 64-bit Ubuntu/Debian users will notice an error when updating the software sources, which looks as follows:
Ubuntu14.04 LTS 64 位操作系统中的节点和 npm 更新存在问题。由于 Google Chrome 存储库不再提供 32 位软件包,因此 64 位 Ubuntu/Debian 用户在更新软件源时会注意到错误,如下所示:
Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/ReleaseUnable to find expected entry 'main/binary-i386/Packages' in Release file (Wrong sources.list entry or malformed file) Some index files failed to download. They have been ignored, or old ones used instead.
无法获取http://dl.google.com/linux/chrome/deb/dists/stable/Release无法在发布文件中找到预期的条目“main/binary-i386/Packages”(错误的 source.list 条目或格式错误的文件) ) 部分索引文件下载失败。它们已被忽略,或使用旧的代替。
So to fix this issue, the repository must be specifically set for 64-bit only. This can be done by the command
因此,要解决此问题,必须专门为 64 位设置存储库。这可以通过命令完成
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
i,e You should set it for 64 bit only before installing node. So the exact procedure to install latest node and npm will be
i,e 您应该只在安装节点之前将其设置为 64 位。因此,安装最新节点和 npm 的确切过程将是
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
I had such an issue and got this solution from here. Hope this will help someone.
我遇到了这样的问题,并从这里得到了这个解决方案。希望这会帮助某人。
回答by Arvind
Here i am going to tell you how to install nodejs compile and install into your Linux Server.
在这里,我将告诉您如何安装 nodejs 编译并安装到您的 Linux 服务器中。
Step 1-:
第1步-:
$ cd /opt/
$ wget https://nodejs.org/dist/v6.2.1/node-v6.2.1.tar.gz
Extract the tar.gz source code
提取 tar.gz 源代码
$ tar -xvf node-*.tar.gz
Step 2-: Compile and install the nodejs.
步骤 2-:编译并安装 nodejs。
$ cd node-v6.2.1
$ ./configure
$ make
$ sudo make install
Note-: If you found error “make command not found”
注意-:如果您发现错误“make command not found”
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential
$ gcc -v
$ make -v
回答by J.D.
Checkout nvm. It manages node distributions for you, so you can have multiple projects running that use different nodejs versions.
结帐nvm。它为您管理节点分发,因此您可以运行多个使用不同 nodejs 版本的项目。
nvmlets you choose exactly which version of node you need. With apt-getyou will always only get the latest version that has been included into debian/ubuntuby those package maintainers, but those are usually very old. Especially in an area like nodejs, this is mostly not suitable.
nvm可让您准确选择所需的节点版本。与apt-get您一起,您将始终只能获得debian/ubuntu那些包维护者包含的最新版本,但那些通常很旧。尤其是像nodejs这样的领域,这大多是不合适的。
回答by Ahmed Hamed
Running Ubuntu Mate 14.04 LTS
运行 Ubuntu Mate 14.04 LTS
- curl -sL https://deb.nodesource.com/setup_4.x| sudo -E bash -
- sudo apt-get install -y nodejs
- nodejs -v
- curl -sL https://deb.nodesource.com/setup_4.x| 须藤 -E bash -
- sudo apt-get install -y nodejs
- nodejs -v
回答by Herman Demsong
This worked for me:
这对我有用:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Hope it helps someone too :)
希望它也能帮助别人:)
回答by user2719152
Assuming you already have npm package and want to upgrade nodejs version:
假设你已经有了 npm 包并且想要升级 nodejs 版本:
sudo npm install -g n
sudo n latest
In case you don't have installed npm package then itstall it using following command:
如果您还没有安装 npm 包,请使用以下命令将其安装:
sudo apt-get install npm
On linux.
在 linux 上。
回答by Mohideen bin Mohammed
Better way to do is,
更好的办法是,
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
based on version can change, setup_6.xinto 7,8 etc
基于版本可以改变,setup_6.x变成7,8等
回答by suraj kumar
wget -qO- https://deb.nodesource.com/setup_X.x | sudo bash -
sudo apt-get install -y nodejs

