help icon indicating copy to clipboard operation
help copied to clipboard

npm not installed along with nodejs

Open totsteps opened this issue 9 years ago • 28 comments

Version: v4.2.6 of node -v Platform: Linux 4.8.0-36-generic #36~16.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux.

Following the guidelines as per https://nodejs.org/en/download/package-manager/, installed nodejs versin-7.x on my machine several times.

But every time npm does not get installed. When typing in 'npm -v' it says, the program 'npm' is currently not installed. You can install it by typing: 'sudo apt install npm'.

What's even strange is, the system displays(node -v) that the installed nodejs version is v4.2.6.

totsteps avatar Mar 28 '17 21:03 totsteps

https://askubuntu.com/questions/1088662/npm-depends-node-gyp-0-10-9-but-it-is-not-going-to-be-installed sudo apt-get install nodejs-dev node-gyp libssl1.0-dev sudo apt-get install npm

johndpope avatar Jul 09 '19 02:07 johndpope

I had the same issue and changing the preferences.d didn't work. the problem is that using "remove" doesn't remove the configuration files and any plugins and settings. simply use the purge option to completely remove the current nodejs installation.

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

itamarlev avatar Jul 15 '19 13:07 itamarlev

Download the file https://deb.nodesource.com/setup_12.x Edit the line 196 that says

DISTRO=$(lsb_release)

to

DISTRO=disco

Set disco or other dist.

chmod +x setup_12.x
sudo ./setup_12.x

then

sudo apt install -y nodejs

fontenele avatar Aug 10 '19 04:08 fontenele

After a hard time, I got npm installed with Carbon version. curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -

The current version 10x did not work. curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

I made sure to purge the nodejs-legacy package from my debian 9 strech 32 bit machine.

Carbon (8.x) is the only version that works on 32 bit Linux machines! The rest silently fallback to the official repository's version, so we never know about why it failed. Instead, the script should prompt the user about not supporting the later versions on legacy systems and they should install the 8.x instead.

prahladyeri avatar Apr 06 '20 17:04 prahladyeri

If you installed node.js package from the official website. The npm part is under folder node-YOURVERSION/deps/npm, so go to that folder and run configure then make & make install to install it and look for the error message during the installation.

suestring7 avatar May 12 '20 07:05 suestring7

write npm -v in the cmd image or in terminal if you use phpStorm

baraa-jabeer avatar Aug 08 '20 22:08 baraa-jabeer

In case this helps anyone, this was my solution. I was using WSL 2 and on windows I had npm installed as well. Check in /usr/bin and see if there is npm in there. Note, when you type "type npm" it redirects you to the windows partition. Yet "type node" does not. In order to fix this and not add windows path to wsl, add the following to /etc/wsl.config (or create it if its not there) with sudo.

[interop] appendWindowsPath=false

Then, close the terminal and restart and see if npm now works.

YSternlicht avatar Mar 02 '21 20:03 YSternlicht

In case somebody comes in here and has the same issue in a Dockerfile while using a Debian slim docker image, just install curl before running curl -fsSL https://deb.nodesource.com/setup_x.x | bash -:

apt-get install curl

EdisonArango avatar Nov 18 '22 04:11 EdisonArango