Why do I get old versions of nodejs and npm when installing with apt-get?
Asked Answered
L

2

33

I have executed the following command in Ubuntu 14.04 64-bit.

sudo apt-get update
sudo apt-get install nodejs modejs-legacy npm

I have the versions

npm -v
1.3.10

nodejs -v
v0.10.25

These are older than the recommended versions for AngularJS 2.

Why does apt-get download old version? How do I update to newer versions?

Leopoldoleor answered 4/1, 2016 at 15:20 Comment(3)
possible duplicate of How can I update Node.js and NPM to the next versions?. It doesn't answer the "why?" question, but that answer to that is, "because old version are what's in Canonical's software repositories for your version of Ubuntu"Haukom
Both Debian and RHEL distros have old versions of node and npm. Not sure why node isn't supporting their linux packages, but it sure makes running servers tricky.Platinumblond
has to do with LTS!Kershner
L
25

Debian/Ubuntu has old version in their package manager, you have to use custom PPA repository as stated here:

https://github.com/nodesource/distributions/blob/master/README.md#debinstall

Setup it with:

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Then install with Ubuntu:

sudo apt-get install --yes nodejs
Lacefield answered 4/1, 2016 at 15:35 Comment(8)
This was the missing piece of the puzzle for me trying to install to Raspberry Pi.Reproductive
Doing this saves the linked repo with a higher priority than the Ubuntu's package manager's default?Ogawa
Yes it will be overwritten by thisLacefield
I understand this is an old thread, but would you happen to know why ubuntu/debian's package manager doesn't update this automatically?Burdette
Don't know, lazy maintainers?Lacefield
This seems to answer the question of how to get the current version, not old versions.Warton
in 2021 use nvm to install any node versionLacefield
Adding a comment so that Google picks up the terms I used when searching: the SyntaxError: Unexpected identifier for import statements is caused by the outdated version of npm.Cristobalcristobalite
S
6

To get the latest version the easiest thing to do is install nvm. nvm install instructions

  1. install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
  2. nvm install v10.15.3
  3. (optional) set default nvm alias default v10.15.3
Superdreadnought answered 20/10, 2019 at 1:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.