distributions icon indicating copy to clipboard operation
distributions copied to clipboard

npm is missing from the package?

Open SystemParadox opened this issue 5 years ago • 8 comments

Hi. We've been using nodesource for a long time now with no problems. However, I tried to install it on a new machine (Debian 10) and it doesn't seem to install npm. It's been a little while since I've done this from scratch, but I thought npm was supposed to be installed by default with the nodejs package?

There is a separate npm package available, but it's just the default Debian one:

$ apt-cache policy npm
npm:
  Installed: (none)
  Candidate: 5.8.0+ds6-4
  Version table:
     5.8.0+ds6-4 700
        700 http://ukdebian.mirror.anlx.net/debian buster/main amd64 Packages

I've definitely installed the nodejs package from nodesource:

$ apt-cache policy nodejs
nodejs:
  Installed: 10.15.2~dfsg-2
  Candidate: 10.15.2~dfsg-2
  Version table:
     10.19.0-1nodesource1 500
        500 https://deb.nodesource.com/node_10.x stretch/main amd64 Packages
 *** 10.15.2~dfsg-2 700
        700 http://ukdebian.mirror.anlx.net/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status

But npm doesn't seem to be included in the nodejs package at all:

$ dpkg -L nodejs
/.
/usr
/usr/bin
/usr/bin/node
/usr/lib
/usr/lib/nodejs
/usr/share
/usr/share/doc
/usr/share/doc/nodejs
/usr/share/doc/nodejs/AUTHORS.gz
/usr/share/doc/nodejs/README.Debian
/usr/share/doc/nodejs/buildinfo_amd64.gz
/usr/share/doc/nodejs/changelog.Debian.gz
/usr/share/doc/nodejs/changelog.gz
/usr/share/doc/nodejs/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/node.1.gz
/usr/bin/nodejs
/usr/share/man/man1/nodejs.1.gz

Have I missed a step during the installation? Where is npm?

Thanks.

SystemParadox avatar Mar 16 '20 18:03 SystemParadox

Same problem here, npm not installed (linux mint).

In my case the reason was that a public key was missing for one of the repos in my apt repo list which caused the first step (curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -) to exit with error after performing "apt-get update".

I ran apt-get update manually to verify and corrected the missing public key (see https://itsfoss.com/ubuntu-update-error/).

After that I could run both steps successfully and it installed npm as well.

HTH

firedog avatar Apr 21 '20 08:04 firedog

I have the same issue but no errors on apt update

The package npm isn't installed

shadowc avatar Aug 22 '20 20:08 shadowc

Some notes:

@SystemParadox looking at your policy output, it says that 10.15.2~dfsg-2 is installed which is the version from ukdebian.mirror.anlx.net not nodesource. It is aware of the nodesource package but did not install it

$ apt-cache policy nodejs
nodejs:
  Installed: 10.15.2~dfsg-2
  Candidate: 10.15.2~dfsg-2
  Version table:
     10.19.0-1nodesource1 500
        500 https://deb.nodesource.com/node_10.x stretch/main amd64 Packages
 *** 10.15.2~dfsg-2 700
        700 http://ukdebian.mirror.anlx.net/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status

For example, here is an Ubuntu VM with the nodesource package installed:

vagrant@vvv:~$ apt-cache policy nodejs
nodejs:
  Installed: 10.23.1-1nodesource1
  Candidate: 10.23.2-1nodesource1
  Version table:
     10.23.2-1nodesource1 500
        500 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages
 *** 10.23.1-1nodesource1 100
        100 /var/lib/dpkg/status
     8.10.0~dfsg-2ubuntu0.4 500
        500 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
     8.10.0~dfsg-2ubuntu0.2 500
        500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages
     8.10.0~dfsg-2 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

I'm currently debugging the same situation with another user, who can reproduce this 100% of the time yet the same provisioning scripts work perfectly for me.

What I think is happening is that apt can't connect to Nodesource and uses the first mirror that works, which is the debian packages, and those don't contain npm.

A fix could be renaming nodejs for Nodesource, or specifying a nodesource version explicitly in the apt-get install command, e.g. sudo apt-get install nodejs=10.23.1-1nodesource1

tomjn avatar Feb 04 '21 12:02 tomjn

Also apt pinning this repo will help avoid the situation, see this comment https://github.com/nodesource/distributions/issues/114#issuecomment-155428532

tomjn avatar Feb 04 '21 13:02 tomjn

Ah I hadn't noticed that! It definitely seems like we need to do something to make sure that nodesource gets a higher priority than the debian repository.

The affected machine is currently unused so it's available if you want me to test anything.

SystemParadox avatar Feb 04 '21 15:02 SystemParadox

I'm now encountering this personally, GH Actions have begun to fail, and other users are encountering this. We've confirmed we're using the Nodesource package not the Debian/Ubuntu packages

tomjn avatar Feb 04 '21 16:02 tomjn

I believe the cause for me was running npm install -g npm as root. In each occasion a purge and reinstall of the nodejs package would fix things.

Instead, the solution to keeping an up to date npm is to instead install npm as the current user in the home dir, and make sure it has a higher priority in PATH, so that when npm install -g npm is ran it doesn't need root access, and no broken-ness occurs

tomjn avatar Feb 05 '21 14:02 tomjn

In my case, the problem was that I needed to run the installer script as root.

osbre avatar May 21 '21 20:05 osbre