Installing latest version of npm on Ubuntu 14.04 (trusty) - node.js

I have
a remote serving running Ubuntu 14.04. I used apt to install node
a local OSx machine running El Capitan. I used hombrew to install node.
This results in the following.
Ubuntu 14.04
> sudo apt-get update
> sudo apt-get install node nodejs npm
> npm --version
1.3.10
> node --version
(emtpy)
> nodejs --version
v0.10.25
OSx
> brew install node
> npm --version
5.6.0
> nodejs --version
-bash: nodejs: command not found
> node --version
v8.11.3
Why are the apt repositories so out of date? The npm version on the server (1.3.10) is 4 versions behind that of OSx machin (5.6.0).
This npm issue even mentions that the apt repositories are quite old / not updated.
Is there a way to install a more recent version of npm on the Ubuntu server?

Download this tar file from nodejs official website
https://nodejs.org/dist/v8.11.4/node-v8.11.4.tar.gz
download, untar and install it via using the following command
sudo make test
sudo make install
It will install 8.11.4 version.
Please note that you can download any version of tar from nodejs officail page and can install it on your Ubuntu server and by using this method you don't need to update your apt packages.

Related

sudo npm i npm or sudo npm install npm#latest -g throws an error of EACCES:permission denied

I have npm v 5.6 and I installed node version 10.1 so the current npm doesn't support node version while updating npm I am getting EACCES permission denied error. I tried removing npm directory and updating via several command the npm version is stuck at 5.6. Help!!
Using Ubuntu v16.04 LTS.
I tried installing different nodejs version too but it also doesnt change npm version(npm v5.6).
visit here for the screenshot
I'd recommend using a version manager (such as nvm) to install multiple versions of Node.js and switch between them at will.
First off, make sure you have git and the build-essential package installed:
sudo apt-get update
sudo apt-get install build-essential git
Then install nvm with cURL (run this command in your terminal):
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
This will clone the nvm repository to ~/.nvm and will make the required changes to your bash profile, so that nvm is available from anywhere in your terminal.
Reload your bash profile:
source ~/.bashrc
and verify the install by typing:
command -v nvm
which should output 'nvm' if the installation was successful.
(if this doesn't work, just close, then reopen your terminal)
And that’s it, nvm is installed and ready to be used.
Now, to download, compile, and install the latest release of Node, run the following from your terminal:
nvm install node
And then in any new shell just use the installed version:
nvm use node
Finally, verify the correct version is being used:
node -v
=> 10.5.0
There's a lot more to using nvm, such as installing multiple Node versions.
You can read more about that here: https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
HTH

Error when I try to install npm on Ubuntu 17.04

I'm trying to install npm on Ubuntu 17.04 but I'm not getting it. I've installed nodejs and nodejs-legacy and when I try to install npm, a message appears saying that npm depends on node-gyp (>= 0.10.9) and won't be installed. If a try to install node-gyp, another dependency appears and successively. Does anybody know how to fix it?
if you use apt-get for install nodejs you can switch version easily:
$ sudo apt-get install npm # install npm
$ sudo npm install -g n # install n nodejs version switcher as global package.
$ sudo n stable # install latest stable version.
install more version: [exmp: 9.1.0]
$ sudo n 9.1.0
reference
I suggest you don't use apt-install to install npm.You can download the bin file from official site.(https://nodejs.org/en/)
Just extract the tar file and setup the path to you system,you can get the latest version!

Node.js will not Update to Latest Version

I currently have node.js version v7.6.0
According to documentation, v8.5.0 is the latest version of node.
I have tried installing it using https://nodejs.org/en/
node -v returns v7.6.0.
I have tried the following commands in Terminal:
[sudo] npm install npm#latest -g
npm install npm#latest -g
sudo apt-get update
sudo n 0.8.21
sudo n latest
lsb_release -a
Each command appears to recognize and install the latest version, but the final message reads:
Installed: v7.6.0
I've altered my BASH Profile to include:
/usr/local/bin/node
/usr/local/bin/npm
My version still shows v7.6.0 as the current version running.
Side Note:
My NPM is up-to-date at version 5.4.2
Is there any other way to update my Node to the current version?
In order to update to the latest version of node, use commands:
nvm use system
nvm run system --version
nvm install node
These commands will bring you to the latest version of node.
Thank you!

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

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?
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
To get the latest version the easiest thing to do is install nvm. nvm install instructions
install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
nvm install v10.15.3
(optional) set default nvm alias default v10.15.3

Yum update or Yum upgrade for nodejs and npm in EC2 server

I am trying to update/upgrade the nodejs and npm packages using "yum" in the EC2 server (Linux 3.4.48-45.46.amzn1.x86_64 x86_64).
The current version of nodejs is 0.10.36 and i want it to be upgraded to 0.12.0
Below is the command:
sudo yum -y upgrade nodejs
But this does not update/upgrade.
Am I missing something? I also tried updating both nodejs and npm , but no luck.
I also did the following for Linux machines:
sudo npm install n -g and then
sudo n 0.12.2
Any help is appreciated.
Thanks

Resources