Showcaselfloyd Showcaselfloyd - 4 months ago 13
Node.js Question

How do I get NPM install just one package?

I'm running Node 6.3.0 on a MackBook I just set up running OS X 10.11

I installed Node using Homebrew and I noticed that when I run

npm install
it installs what amounts to dozens and dozens of extra packages.

For instance when I run
npm install gulp --save
it installs gulp but when I look in the
node_modules
directory I see what looks like 30 or 40 extra folders. This is different then when I run npm at home on my Linux box. When I do that I only see the one directory.

Am I doing something incorrectly?

Answer

You are probably using an older version of npm (< 3) on your Linux box. With npm 3 they changed the way they store dependencies and try to flatten the dependencies tree. e.g. If you had a project A that requires B and that requiring B it would look like this:

npm 2:

A/node_modules/B/node_modules/C

npm 3:

A/node_modules/B
A/node_modules/C

Hope this helps.