diff options
author | isaacs <i@izs.me> | 2010-11-06 22:59:24 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-11-06 22:59:24 +0300 |
commit | da8557a02fe1a5e85c79b75350e2988bd9c2109b (patch) | |
tree | ed34372efe0bdedcf6c7ecc4f344a76d613cce62 /README.md | |
parent | 2881227e0b2688f9a72c8fcf09bceaab2d233f5c (diff) |
document programmatic usage
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -105,13 +105,27 @@ Or, if that fails, make uninstall -## Install Problems - -There's was an issue prior to npm version 0.2.0 where packages whose names contained -hyphen characters would be odd. - -If you've installed any packages with `-` in the name prior to 0.2.0, then you ought -to remove and reinstall them. +## Using npm Programmatically + +If you would like to use npm programmatically, you can do that as of +version 0.2.6. It's not very well documented, but it IS rather simple. + + var npm = require("npm") + npm.load(myConfigObject, function (er) { + if (er) return handlError(er) + npm.commands.install(["some", "args"], function (er, data) { + if (er) return commandFailed(er) + // command succeeded, and data might have some info + }) + npm.on("log", function (message) { .... }) + }) + +See `./cli.js` for an example of pulling config values off of the +command line arguments. You may also want to check out `npm help +config` to learn about all the options you can set there. + +As more features are added for programmatic access to the npm library, +this section will likely be split out into its own documentation page. ## More Docs |