Tuesday 15 June 2010

javascript - How to programmatically get the location where npm installs global modules -


I want to search the folder where npm installs the global module. This question is similar, but the answer is globally Does not work for the installed module:

From the node website:

< P> Globally - it runs the module in {prefix} / lib / node_modules, and puts executable files in {prefix} / bin, where {prefix} is usually something like / usr / local. Refix} / share / man, the man places the page in front, if they provide again.

To get the prefix:

  Prefix Npm config   

Edit:

Use NPM NPM module to do this from the node, something like this will work:

  var npm = require ("npm") var myConfigObject = {} npm.load (myConfig object , Function (er) {if return} handle error (er) Console.log (npm.get ('prefix'))}}    

No comments:

Post a Comment