When deploying Node and NPM on Ubuntu 20.04 I noticed that when you run sudo apt install npm it details a massive number of dependencies that it want's to install with it. Why is this? Surely it doesn't require all these packages to run the package manager?
Asked
Active
Viewed 6,114 times
16
Tom Dickson
- 283
- 3
- 6
-
JavaScript is not known for being light. Is this a serious question? You are asking if dependencies are really dependencies. – Nmath Aug 25 '20 at 05:22
-
"Why is this?" is asking for opinions. You need to ask the creator of npm. – Rinzwind Aug 25 '20 at 06:43
-
1@Rinzwind If I was looking for an opinion it would have been "What is your opinion" smh. Nmath, I understand that JS has a lot of dependencies but at the time of writing that I didn't realise NPM itself was written in JS, so it makes sense now that it has so many dependencies. – Tom Dickson Aug 27 '20 at 07:10
-
1Glad I'm not the only one who had this question... – jobo3208 Jun 07 '22 at 00:51
1 Answers
12
You can reduce the number of installed packages by providing --no-install-recommends:
sudo apt-get install npm --no-install-recommends
Comparison for minimal 20.04 LTS system:
sudo apt-get install npm0 upgraded, 516 newly installed, 0 to remove and 0 not upgraded.
sudo apt-get install npm --no-install-recommends0 upgraded, 313 newly installed, 0 to remove and 0 not upgraded.
N0rbert
- 103,523
-
7
-
The big recommanded pkgs comes from "build-essential". Cf
apt install -s -o Debug::pkgDepCache::AutoInstall=true npm 2>&1 | grep Recommends– Pascal Pixel Rigaux Jan 11 '22 at 10:13 -
Nowadays on raspbian bases on Debian 10 Buster form npm version
5.8.0+ds6-4+deb10u2...sudo apt install npm= 247 deps andsudo apt install npm --no-install-recommends= 246 deps :D So almost no difference. – mikep Jun 09 '22 at 07:33 -
Why is this not the default? This brought the install size down from 600MB to 117MB. The Windows installer (the Node install MSI) by comparison is only 25MB. – Ian Smith Nov 22 '23 at 22:49
-
just came here for ubuntu 22.04 and the no-install-recommends brought it down from 600+ to 28MB (according to apt anyhow). I'll take the win, because this npm version is crufty and old just like the apt provided
nodejs; i want it as a quick way to bootstrap a node version manager to get a modern toolchain... – Steven Lu Aug 06 '24 at 16:54 -