0

I installed nodejs 4 on Ubuntu 14.04 using node's official PPA, as described here. It seems like npm v2 is the default so I upgraded npm to v3 using itself (npm update --global). Version 3 is required by the software I am deploying.

Everything is fine until I run regular security updates etc. using apt-get update/upgrade and npm gets consistently downgraded to v2.

Is there any way to prevent npm global packages (specifically npm itself) being altered by apt-get?

Some config files in case useful:

# /etc/apt/sources.list deb http://mirrors.digitalocean.com/ubuntu trusty main restricted deb-src http://mirrors.digitalocean.com/ubuntu trusty main restricted deb http://mirrors.digitalocean.com/ubuntu trusty-updates main restricted deb-src http://mirrors.digitalocean.com/ubuntu trusty-updates main restricted deb http://mirrors.digitalocean.com/ubuntu trusty universe deb-src http://mirrors.digitalocean.com/ubuntu trusty universe deb http://mirrors.digitalocean.com/ubuntu trusty-updates universe deb-src http://mirrors.digitalocean.com/ubuntu trusty-updates universe deb http://mirrors.digitalocean.com/ubuntu trusty multiverse deb-src http://mirrors.digitalocean.com/ubuntu trusty multiverse deb http://mirrors.digitalocean.com/ubuntu trusty-updates multiverse deb-src http://mirrors.digitalocean.com/ubuntu trusty-updates multiverse deb http://mirrors.digitalocean.com/ubuntu trusty-backports main restricted universe multiverse deb-src http://mirrors.digitalocean.com/ubuntu trusty-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu trusty-security main deb-src http://security.ubuntu.com/ubuntu trusty-security main deb http://security.ubuntu.com/ubuntu trusty-security universe deb-src http://security.ubuntu.com/ubuntu trusty-security universe # /etc/apt/sources.list.d/nodesource.list deb https://deb.nodesource.com/node_4.x trusty main deb-src https://deb.nodesource.com/node_4.x trusty main 
1
  • Ah, one more thing, what do you get for apt-cache policy nodejs? Commented Sep 7, 2016 at 22:20

1 Answer 1

0

After a bit more searching I found this github thread which seems to suggest you are going to need to do some pinning. I suggest you try adding creating the file /etc/apt/preferences.d/nodejs with the below contents as suggested in that issue.

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

You can use the apt-cache policy nodejs command before and after configuring pinning to verify that it changes the priorities.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.