简体   繁体   English

如何在Ubuntu上将Node js版本升级到0.12.4

[英]How to upgrade Node js version to 0.12.4 on Ubuntu

I want to upgrade Node JS version on Ubuntu. 我想在Ubuntu上升级Node JS版本。

I tried many commands but its version is still the older ie v0.10.37. 我尝试了很多命令,但它的版本仍然是旧的,即v0.10.37。

I tried: 我试过了:

sudo npm install -g n
sudo n install 0.12.4
sudo n use 0.12.4

Also tried with nvm but non of them works for me. 也试过nvm,但不适用于我。 How can I upgrade Node Js version to 0.12.4? 如何将Node Js版本升级到0.12.4?

Use npm in order to upgrade node 使用npm升级节点

First Clean the cache and try 首先清理缓存并尝试

sudo npm cache clean -f
sudo npm install -g n
sudo n 0.12.4

Then create a symbolic link(It is needed only sometimes, first try with these three commands. If it doesnot work add this.) 然后创建一个符号链接(有时只需要它,首先尝试使用这三个命令。如果它不起作用,请添加它。)

It will be updated to 0.12.4 Version. 它将更新为0.12.4版本。

It could be enough just to install n module: 只安装n模块就足够了:

sudo npm install -gn

and then simply run: 然后简单地运行:

sudo n 0.12.4

The trick is that it may not be updated in your current terminal session. 诀窍是它可能不会在您当前的终端会话中更新。 So you can simply open one more tab in your terminal or just another terminal and check your nodejs version by: 因此,您只需在终端或另一个终端中再打开一个选项卡,并通过以下方式检查您的nodejs版本:

node --version

That's it, output will be v0.12.4 就是这样,输出将是v0.12.4

The official doc from nodejs repository points to this : https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories#installing-node-js-v0-12 来自nodejs存储库的官方文档指向: https ://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories#installing-node-js-v0-12

Just follow it and you'll have the 0.12.4. 按照它,你将获得0.12.4。

Try running this in terminal: 尝试在终端中运行:

nvm install 5.10.1
nvm use 5.10.1

The version may be change. 版本可能会发生变化。

Cheers! 干杯!

Execute following comand to upgrade nodejs to 0.12.x 执行以下命令将nodejs升级到0.12.x

Note the new setup script name for Node.js v0.12 请注意Node.js v0.12的新安装脚本名称

curl -sL https://deb.nodesource.com/setup_0.12 | curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - sudo bash -

Then install with: 然后安装:

sudo apt-get install -y nodejs sudo apt-get install -y nodejs

Just ignore warning. 只是忽略警告。 By executing both commands it worked for me on Ubuntu 14.04 通过执行这两个命令,它在Ubuntu 14.04上为我工作

On Ubuntu 16.04 Ubuntu 16.04上

There is no special or dedicated comand to upgrade node version. 升级节点版本没有特殊或专用的命令。 The correct way to install or upgrade node on ubuntu is: 在ubuntu上安装或升级节点的正确方法是:

1) download the distribution you wish from nodejs official site , move the file into a known path 1)从nodejs官方网站下载您希望的发行版,将文件移动到已知路径

2) open a terminal and run: > sudo tar -C /usr/local --strip-components 1 -xzf "known path/name_of_the_distribution_file...gz 2)打开终端并运行:> sudo tar -C /usr/local --strip-components 1 -xzf "known path/name_of_the_distribution_file...gz

3) test if everything is ok: open a new terminal and run node --version . 3)测试一切是否正常:打开一个新终端并运行node --version It should echo the version you downloaded and installed/upgraded. 它应该回应您下载和安装/升级的版本。

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

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