Reputation: 44649
I'm trying to access the location on the disk of the global node modules (from within a node module).
I know I can enter npm root -g
on the command line, but this is awfully SLOW.
Does any of you know a way to get this information reliably and in a timely fashion (without requiring users to setup any global Env variables)?
Upvotes: 6
Views: 35615
Reputation: 13562
You probably cannot do this in pure javascript way, but you can just look for the npm location:
$ which npm
/usr/local/bin/npm
$ ls -al /usr/local/bin/npm
... /usr/local/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
so the global node_modules
is /usr/local/lib/node_modules
Upvotes: 14