3

I am using Ionic and my builds are failing. It says I need to have the latest npm and node.js. Sadly, my attempts so far from another topic and sudo apt-get update and sudo apt-get upgrade etc is failing to move the version of t 14.17.3 LTS which the website says is the latest LTS.

https://nodejs.org/en/download/

I have many setups and do not want to break others too. It would be very kind if someone can provide the right commands to update to the latest npm and nodejs LTS.

The topics I went through has commands to specific versions and are old. Thanks.

Update 1 :

I installed nodejs 14 from Snap store. But no idea where it is now. When I use nodejs --version it shows v10.

user227495
  • 4,089
  • 17
  • 56
  • 101

2 Answers2

7

I usually use nvm.
With this tool you can utilize any version of node, side by side on the same machine.

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

Then download your desired node version nvm install 14 .

Nvm has many other options for managing your node runtimes so check the man page.

user2417031
  • 406
  • 3
  • 7
2

You can do this using installation instructions from official Node.js website - Installing Node.js via package manager. Namely for Ubuntu you'll be directed to nodesource/distributions at GitHub. Find the following paragraph - Installation instructions. It stated for example:

Node.js v14.x:

Using Ubuntu

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

Serg
  • 824
  • 7
  • 14
  • 3
    Thanks, even after trying the command as root, it says nodejs is already the newest version (10.19.0~dfsg-3ubuntu1). – user227495 Jul 28 '21 at 18:36
  • That just means it's the latest version of nodejs that is available in your ubuntu repo. To update beyond what is included with your version of ubuntu (20.04?), you need to use the above method offered by @Serg – DJ Far Jun 11 '23 at 15:25