npm not installed along with nodejs
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.
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
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..
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
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.
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.
write npm -v in the cmd
or in terminal if you use phpStorm
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.
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