malarres
malarres

Reputation: 2946

npm install global vs local installing different things

When I install a package with --global I get different results than when I install it locally.

Example Installing https://github.com/sverweij/dependency-cruiser

$ npm install --save-dev dependency-cruiser

I get

+ [email protected]
added 62 packages from 63 contributors and audited 491 packages in 14.511s

And I cannot use depcruise (a command explained in the repo doc)

However

$ npm install --global dependency-cruiser

I get

C:\Users\me\AppData\Roaming\npm\depcruise-fmt -> C:\Users\me\AppData\Roaming\npm\node_modules\dependency-cruiser\bin\depcruise-fmt.js
C:\Users\me\AppData\Roaming\npm\dependency-cruiser -> C:\Users\me\AppData\Roaming\npm\node_modules\dependency-cruiser\bin\dependency-cruise.js
C:\Users\me\AppData\Roaming\npm\depcruise -> C:\Users\me\AppData\Roaming\npm\node_modules\dependency-cruiser\bin\dependency-cruise.js
C:\Users\me\AppData\Roaming\npm\dependency-cruise -> C:\Users\me\AppData\Roaming\npm\node_modules\dependency-cruiser\bin\dependency-cruise.js
+ [email protected]
added 115 packages from 89 contributors in 18.422s

And then I can use depcruise

Thanks,

Upvotes: 1

Views: 2047

Answers (1)

Muhammad Zeeshan
Muhammad Zeeshan

Reputation: 4748

In npm, there are two ways to install things:

  1. globally — This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they’re supplied.

  2. locally — This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren’t installed at all.

That's the reason you are seeing different package size while both installation. Reference: Node.js Doc's

Upvotes: 2

Related Questions