Closed eugenetriguba closed 2 years ago
Thank you, @eugenetriguba.
How can npm not be present?
node should always come with npm, but someone could do something silly and npm uninstall -g npm
, i suppose
Hmm not sure how my install got into that state then. It was on a fresh Ubuntu install and I hadn’t done anything to remove npm. I’ll see if I can try to get a set of steps to reproduce it 🙂
Here's a minimally reproducible example :slightly_smiling_face:
$ docker pull ubuntu:21.10
$ docker run -it ubuntu:21.10 /bin/bash
root@193819ab21c1:/# apt update && apt upgrade
...
root@193819ab21c1:/# apt install nodejs
...
root@ed8c00e465dc:/# node --version
v12.22.5
root@ed8c00e465dc:/# npm --version
bash: npm: command not found
npm
is a separate install via apt install npm
.
On the page for the package, it shows npm
as a "suggest" install but not a dependency.
I had installed yarn
and hadn't had a need to install npm
yet and was finding that behavior from the nvm script odd.
(this is one of the many reasons node should never be installed via apt; it’s supposed to include npm)
It is nevertheless a situation that a user of nvm can run into though. I would think it would be desirable for nvm to handle that case then, regardless of the opinions around not including it with the nodejs
package, since to a user it is a confusing experience.
That could be done by telling the user it is not installed, explicitly throwing an error that it is not installed with a more friendly error message, or at least documenting that nvm
expects the system install to have nodejs and npm available.
Not unique to apt
though. It is also an optional install with Arch Linux. I'm not sure on how many Linux distributions that is the case.
$ docker pull archlinux
$ docker run -it archlinux /bin/bash
[root@69653621239e /]# pacman -Syu
...
[root@69653621239e /]# pacman -S nodejs
...
[root@69653621239e /]# node --version
v17.6.0
[root@69653621239e /]# npm --version
bash: npm: command not found
apt's node package should include npm instead.
Previous behavior:
Now, we'll simply list that it is not installed: