How to update node linux

How do I update Node.js?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.

But I have no idea how to update Node.js. Any suggestions? (I’m using Node.js 0.4.1 and want to update to Node.js 0.6.1.)

Possible duplicate: How can I update NodeJS and Npm for the next versions? . (should at the very least be linked)

Things have gotten quite a bit easier since this question was first answered (if you don’t need version management) : All platforms (Windows, Mac & Linux)

30 Answers 30

To upgrade Node you may first want to see which version of Node.js you are currently using:

Find out which versions of Node.js you may have installed and which one of those you’re currently using:

List all versions of Node.js available for installation:

Apparently for Windows the command would be rather like this:

Assuming you would pick Node.js v8.1.0 for installation you’d type the following to install that version:

You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:

In 2013 I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac, for more recent instructions see above.

Update from 2017: Please mind, Mr. Walsh himself recommended to update Node.js just using nvm instead.

Alternatively pick a specific version and install like this:

For production environments you might want to pay attention to version numbering and be picky about odd/even numbers.

You should credit your source — your answer is quoted from David Walsh’s blog: davidwalsh.name/upgrade-nodejs. It should also be noted that this method has major caveats, some rather destructive, as seen in the comments on the original blog post.

Unfortunately that din’t worked for me.. was doing exact as described on a Linux machine — ‘node -v’ before and after showed ‘v0.10.5’

@Rob Imig : Globally installed scripts usually go to places like /usr/local/bin that require special permissions for installation. Further information: github.com/npm/npm/issues/3139 A possible fix/workaround (if you really want to avoid using sudo ): stackoverflow.com/questions/16724259/npm-command-sudo-or-not

Seems to work for me but just followed the link to David Walsh’s Blog above and he explicitly says not to use it — be warned!

It’s a Bash script that lets you download and manage different versions of node. Full source code is here.

There is a separate project for nvm for Windows: github.com/coreybutler/nvm-windows

Below are the full steps to use NVM for multiple version of node on windows

enter image description here

  1. download nvm-setup.zip extract and install it.
  2. execute command nvm list available from cmd or gitbash or powershell, this will list all available version of node
  3. use command nvm install version e.g. nvm install 12.14.0 to install on the machine
  4. last once installed use nvm use version to use newer version e.g. nvm use 12.14.0
Читайте также:  Установка libpcap astra linux

@PhilHannent as per NVM github page, they don’t support NVM on windows, so one can say that «there is no official NVM for windows»

For windows just download latest version and install it. It will be automatically updated to new version you downloaded.

Any OS (including Windows, Mac & Linux)

Updated October 2022

Just go to the official Node.js site (nodejs.org), download and execute the installer program.

It will take care of everything and with a few clicks of ‘Next’ you’ll get the latest Node.js version running on your machine. Since 2020 it’s the recommended way to update NodeJS. It’s the easiest and least frustrating solution.

Download NodeJS for Windows, buttons

Download NodeJS for Win/Mac/Source Code buttons

  • NodeJS installation includes NPM (Node package manager).
  • To check your NPM version use npm version or node —version .
  • If you prefer CLI, to update NPM use npm install -g npm and then npm install -g node .
    • For more details, see the docs for install command.
    • Windows, Linux, MacOS, IBM AIX.
    • For Docker users, here’s the official Node.js image.
    • For more information on installing Node.js on a variety of less-common operating systems, see this page (there’s even Node for Android!).

    If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command msiexec /package [node msi]

    If my answer is helpful, don’t forget to upvote it
    (here is the original answer by Anmol Saraf, upvote it too)

    Источник

    2 Ways to Update or Upgrade Node.js Version in Ubuntu.

    This article is for “2 Ways to Update/Upgrade Node.js version to the latest version in Ubuntu Linux Systems”.

    It is an Open Source and cross-platform Application. So NodeJS can run on various platforms like Linux, Windows, and Mac.

    NodeJS can be scale-up and down as per the need. Also, it handles more requests because of its single-threaded behaviour.

    The biggest giant Industries like Walmart, PayPal, Netflix, etc. use Node JS.

    Then in 2010, they got their Node Package manager (NPM). Which is one of the largest package registries in today’s world.

    If you want to learn more about Node.js then you can refer to the link.

    So the 2 Ways to Upgrade the Node.js Version are as follows.

    1. Update Node.js Version using NPM (Node Package Manager) in Ubuntu.
    2. Upgrade Node.js Version using NVM (Node Version Manager) in Ubuntu.

    Prerequisite

    Any Debian distributors like Ubuntu, Linux Mint etc. for our setup will use Ubuntu 20.04 with sudo access.

    Update Node.js Version Using Node Package Manager(NPM) in Ubuntu.

    Before Update Node.js always check the current version for the node and NPM command use -v option.

    So now install the “n” module in Node.js via NPM because the “n” module manages the version for the Node.js.

    After installation for the “n” module globally, update the node to stable version.

    So by using the above command the stable version for Node.js 14.17 with NPM 6.14 gets upgraded.

    if you get the error for any environment, then use -E env “PATH=$PATH” n stable with sudo command.

    $ sudo -E env "PATH=$PATH" n stable 

    So the above command will also update the stable version for Node.js.

    Let’s Upgrade the latest version for Node.js with the “n” module.

    This will update the node to the latest version 16.9.0 and NPM 7.21.1.

    Can you update the version of our choice?

    Assume that any developer needs a Node.js 12 version to upgrade or install.

    Sure can do that instead of latest put the version.

    Want to know more about n module follow the official website of NPM.

    Before going to the second Method have a look at “how to install NVM(Node JS Version Manager)”. Which will be very helpful to upgrade Node.js Versions.

    How to Install Node JS Version Manager (NVM) in Linux.

    So with the help of NVM can install as many versions for the node.js and switch the version as required.

    Also, use as many node versions in a single environment and switch according to our needs. so let’s download the NVM script with the help of the curl command.

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

    After installation of NVM on Ubuntu, we will set the source and list the node version by using NVM command.

    So let’s use the above command and use NVM command to Upgrade Node.js Version on Ubuntu Linux.

    Upgrade Node.js Version using NVM (Node Version Manager) in Ubuntu.

    So first list the versions for node js via NVM command in Ubuntu.

    $ nvm list-remote OUTPUT: v14.17.5 (LTS: Fermium) v14.17.6 (Latest LTS: Fermium) v15.0.0 v15.0.1 v15.1.0 v15.2.0 v15.2.1 v15.3.0 v15.4.0 v15.5.0 v15.5.1 v15.6.0 v15.7.0 v15.8.0 v15.9.0 v15.10.0 v15.11.0 v15.12.0 v15.13.0 v15.14.0 v16.0.0 v16.1.0 v16.2.0 v16.3.0 v16.4.0 v16.4.1 v16.4.2 v16.5.0 v16.6.0 v16.6.1 v16.6.2 v16.7.0 v16.8.0

    let’s Update the stable version 14 for Node.js in Ubuntu by using the NVM install command.

    Let’s install the nodejs 16 version on Ubuntu and check the version of node js by using node and npm commands.

    So we can see the node version installed is 16 on Ubuntu System. Check the version with “node -v” and “npm -v”.

    Let’s switch the version from 16 to 14 by using NVM command.

    We have Update the version for Node.js successfully, let’s check the version for the node.

    So NVM is very simple to use, also on a single environment we can have a multiple Node.js version.

    Find Some Useful links for to Install MongoDB on Docker. Keep Sharing and Supporting us.

    Источник

    updating nodejs on ubuntu 16.04

    I was recently going through the version of node in my ubuntu 16.04 when node -v command was used it shows me version 6.9.1 but when nodejs -v it shows 6.9.2 previously before using this commands npm update command was used. Now what’s these difference in node -v and nodejs -v ? and how to update to the latest LTS version of node/nodejs?

    17 Answers 17

    To update, you can install n

    You can also use sudo n current or sudo n lts if you want more guarantee of stability and don’t need the latest bleeding-edge features.

    @thund I upvoted your comment, but actually sudo n current does not exist, I think you mean sudo n stable

    node v12 (Old)

    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs 

    node v14 (For new users: install this one):

    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs 

    node v15 (Current version):

    curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash - sudo apt-get install -y nodejs 

    Other older versions: Just replace the desired version number in the link above.

    Optional: install build tools

    To compile and install native packages

    sudo apt-get install -y build-essential 

    To update node to the latest version just:

    sudo apt update sudo apt upgrade 

    To keep npm updated

    To find out other versions try npm info npm and in versions find your desired version and replace [version-tag] with that version tag in npm i -g npm@[version-tag]

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash 

    Test your installation:

    close your current terminal, open a new terminal, and run:

    Use it to install as many versions as u like:

    nvm install 8 # Install nodejs 8 nvm install --lts # Install latest LTS (Long Term Support) version 

    List installed versions:

    Use a specific version:

    nvm use 8 # Use this version on this shell 

    Set defaults:

    nvm alias default 8 # Default to nodejs 8 on this shell nvm alias default node # always use latest available as default nodejs for all shells 

    I spent few hours trying to install Node 16 on my Ubuntu 14.04.6 using curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash — . This Solution works fine for me. Thanks

    Use n module from npm in order to upgrade node

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

    To upgrade to latest version (and not current stable) version, you can use

    sudo apt-get install —reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n

    Use sudo apt-get install —only-upgrade nodejs to upgrade node (and only upgrade node) using the package manager.

    The package name is nodejs , see https://stackoverflow.com/a/18130296/4578017 for details.

    You can also use nvm to install and update node.

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash 

    Then restart the terminal, use nvm ls-remote to get latest version list of node, and use nvm install lts/* to install latest LTS version.

    nvm is more recommended way to install or update node, even if you are not going to switch versions.

    Difference: When I first installed node, it installed as ‘nodejs’. When I upgraded it, it created ‘node’. By executing node, we are actually executing nodejs. Node is just a reference to nodejs. From my experience, when I upgraded, it affected both the versions (as it is supposed to). When I do nodejs -v or node -v, I get the new version.

    Upgrading: npm update is used to update the packages in the current directory. Check https://docs.npmjs.com/cli/update

    To upgrade node version, based on the OS you are using, follow the commands here https://nodejs.org/en/download/package-manager/

    Please refer nodejs official site for installation instructions at the following link

    Anyway, please find the commands to install nodejs version 10 in ubuntu below.

    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs 

    Источник

Оцените статью
Adblock
detector