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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30723507/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:51:11  来源:igfitidea点击:

How to upgrade Node js version to 0.12.4 on Ubuntu

node.jsubuntu

提问by StormTrooper

I want to upgrade Node JS version on Ubuntu.

我想在 Ubuntu 上升级 Node JS 版本。

I tried many commands but its version is still the older i.e 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. How can I upgrade Node Js version to 0.12.4?

也尝试过 nvm 但它们都不适合我。如何将 Node Js 版本升级到 0.12.4?

回答by Sravan

Use npmin 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.4Version.

它将更新为0.12.4版本。

回答by oleh.meleshko

It could be enough just to install nmodule:

仅安装n模块就足够了:

sudo npm install -g n

sudo npm install -g n

and then simply run:

然后只需运行:

sudo n 0.12.4

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

node --version

That's it, output will be v0.12.4

就是这样,输出将是 v0.12.4

回答by Pierre Inglebert

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。

回答by jlerma

Try running this in terminal:

尝试在终端中运行它:

nvm install 5.10.1
nvm use 5.10.1

The version may be change.

版本可能会改变。

Cheers!

干杯!

回答by user5539127

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| sudo bash -

curl -sL https://deb.nodesource.com/setup_0.12| 须藤 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 上对我有用

回答by Francesco

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 上安装或升级 node 的正确方法是:

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. It should echo the version you downloaded and installed/upgraded.

3)测试一切是否正常:打开一个新终端并运行node --version. 它应该与您下载和安装/升级的版本相呼应。