Browse files

document programmatic usage

  • Loading branch information...
1 parent 2881227 commit da8557a02fe1a5e85c79b75350e2988bd9c2109b @isaacs isaacs committed Nov 6, 2010
Showing with 21 additions and 7 deletions.
  1. +21 −7
@@ -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

0 comments on commit da8557a

Please sign in to comment.