0

On Debian sid, to install a web service, I ran a script which added NodeJS repo and installed nodejs package. The problem is apt resolved it to Debian's package version 8.11.2~dfsg-1, which does not include npm for some reason, instead of NodeJS repo's version 8.11.2-1nodesource1. The lack of npm messed with the script that expected it to be present after installation of nodejs.

I solved it by manually doing apt install nodejs=8.11.2-1nodesource1, but that's a temporary workaround. Is there a way I can specify on my script to prefer particular repository regardless of version?

EDIT

# apt policy nodejs
nodejs:
  Installed: 8.11.2-1nodesource1
  Candidate: 8.11.2-1nodesource1
  Version table:
 *** 8.11.2-1nodesource1 500
        500 https://deb.nodesource.com/node_8.x sid/main arm64 Packages
        100 /var/lib/dpkg/status
     8.11.2~dfsg-1 990
        990 http://deb.debian.org/debian unstable/main arm64 Packages
  • 2
    What does apt policy nodejs output? – Stephen Kitt Jun 6 '18 at 9:16
  • 1
    @StephenKitt, edited. – Oxwivi Jun 7 '18 at 17:53
2

Is there a way I can specify on my script to prefer particular repository regardless of version?

You should pin the external source using the origin option to assign a high priority to "the external source" instead of using the release name.

e,g: Add the following lines to your /etc/apt/preferences.d/preferences:

Package: *
Pin: origin deb.nodesource.com
Pin-Priority: 1001

The apt-cache policy nodejs will be:

Candidate: 8.11.2-1nodesource1

Version table:
     8.11.2-1nodesource1 1001
       1001 https://deb.nodesource.com/node_8.x sid/main amd64 Packages
     8.11.2~dfsg-1 500
        500 http://deb.debian.org/debian sid/main amd64 Packages

The package nodejs will be installed from nodsource.com through apt install nodejs

Generally if you add the nodejs source (using the setup script) the package nodejs will be installed from nodesource.com without adding the complete package name to apt or using pinning way. (it can be an issue and you can report it here).

If the package available from multiples repository (debian repo and external repo) you can use the debian release tag to install the package from debian repository. let's say the nodejs is pinned to 1001 and you need to install the package from debian Sid:

apt install nodejs/unstable

AptPreferenecs

Edit

The package nodejs is pinned to 990 , it will be installed from debian repository. remove the nodejs from your preferences file then run:

apt update
apt install nodejs

The package nodejs should be installed from nodesource repository.

  • The script added the repo and it still preferred dfsg package. I edited question with apt policy. – Oxwivi Jun 7 '18 at 17:55
  • @Oxwivi remove the pinned package then you will be able to install the package from nodesource. – GAD3R Jun 7 '18 at 17:57
  • I did not pin anything, this is the policy Stephen asked for before acting upon the suggestion in your answer. – Oxwivi Jun 7 '18 at 18:04
  • 1
    /etc/apt/preferences.d/preferences is empty as well. – Oxwivi Jun 7 '18 at 18:05
  • @Oxwivi changing the pin priority to 1001 of the package nodejs following the answer may instruct apt to install the package from nodesouce. – GAD3R Jun 7 '18 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.