2015-01-08 23:37:26 +01:00
|
|
|
npm(1) -- a JavaScript package manager
|
2011-11-21 18:48:45 +01:00
|
|
|
==============================
|
2014-04-16 00:31:36 +02:00
|
|
|
[![Build Status](https://img.shields.io/travis/npm/npm/master.svg)](https://travis-ci.org/npm/npm)
|
2011-11-21 18:48:45 +01:00
|
|
|
## SYNOPSIS
|
|
|
|
|
|
|
|
This is just enough info to get you up and running.
|
|
|
|
|
|
|
|
Much more info available via `npm help` once it's installed.
|
|
|
|
|
|
|
|
## IMPORTANT
|
|
|
|
|
2013-06-12 19:59:44 +02:00
|
|
|
**You need node v0.8 or higher to run this program.**
|
2011-11-21 18:48:45 +01:00
|
|
|
|
|
|
|
To install an old **and unsupported** version of npm that works on node 0.3
|
|
|
|
and prior, clone the git repo and dig through the old tags and branches.
|
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
## Super Easy Install
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-09-24 23:41:07 +02:00
|
|
|
npm comes with [node](http://nodejs.org/download/) now.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
### Windows Computers
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-09-24 23:41:07 +02:00
|
|
|
[Get the MSI](http://nodejs.org/download/). npm is in it.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
### Apple Macintosh Computers
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-09-24 23:41:07 +02:00
|
|
|
[Get the pkg](http://nodejs.org/download/). npm is in it.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
### Other Sorts of Unices
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
Run `make install`. npm will be installed with node.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
If you want a more fancy pants install (a different version, customized
|
|
|
|
paths, etc.) then read on.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
## Fancy Install (Unix)
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2012-08-15 05:27:28 +02:00
|
|
|
There's a pretty robust install script at
|
2015-01-08 23:37:26 +01:00
|
|
|
<https://www.npmjs.com/install.sh>. You can download that and run it.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-05-01 20:09:00 +02:00
|
|
|
Here's an example using curl:
|
|
|
|
|
2015-01-08 23:37:26 +01:00
|
|
|
curl -L https://npmjs.com/install.sh | sh
|
2014-05-01 20:09:00 +02:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
### Slightly Fancier
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
You can set any npm configuration params with that script:
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2013-03-07 00:41:06 +01:00
|
|
|
npm_config_prefix=/some/path sh install.sh
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
Or, you can run it in uber-debuggery mode:
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2013-03-07 00:41:06 +01:00
|
|
|
npm_debug=1 sh install.sh
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
### Even Fancier
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
Get the code with git. Use `make` to build the docs and do other stuff.
|
|
|
|
If you plan on hacking on npm, `make link` is your friend.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
If you've got the npm source code, you can also semi-permanently set
|
|
|
|
arbitrary config keys using the `./configure --key=val ...`, and then
|
|
|
|
run npm commands by doing `node cli.js <cmd> <args>`. (This is helpful
|
|
|
|
for testing, or running stuff without actually installing npm itself.)
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2015-01-08 23:37:26 +01:00
|
|
|
## Windows Install or Upgrade
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2015-01-08 23:37:26 +01:00
|
|
|
You can download a zip file from <https://github.com/npm/npm/releases>, and unpack it
|
2011-12-01 01:45:26 +01:00
|
|
|
in the same folder where node.exe lives.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2015-01-08 23:37:26 +01:00
|
|
|
The latest version in a zip file is 1.4.12. To upgrade to npm 2, follow the
|
|
|
|
Windows upgrade instructions in the npm Troubleshooting Guide:
|
|
|
|
|
|
|
|
<https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows>
|
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
If that's not fancy enough for you, then you can fetch the code with
|
|
|
|
git, and mess with it directly.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
|
|
|
## Installing on Cygwin
|
|
|
|
|
|
|
|
No.
|
|
|
|
|
|
|
|
## Uninstalling
|
|
|
|
|
|
|
|
So sad to see you go.
|
|
|
|
|
|
|
|
sudo npm uninstall npm -g
|
|
|
|
|
|
|
|
Or, if that fails,
|
|
|
|
|
|
|
|
sudo make uninstall
|
|
|
|
|
|
|
|
## More Severe Uninstalling
|
|
|
|
|
|
|
|
Usually, the above instructions are sufficient. That will remove
|
|
|
|
npm, but leave behind anything you've installed.
|
|
|
|
|
|
|
|
If you would like to remove all the packages that you have installed,
|
|
|
|
then you can use the `npm ls` command to find them, and then `npm rm` to
|
|
|
|
remove them.
|
|
|
|
|
|
|
|
To remove cruft left behind by npm 0.x, you can use the included
|
|
|
|
`clean-old.sh` script file. You can run it conveniently like this:
|
|
|
|
|
|
|
|
npm explore npm -g -- sh scripts/clean-old.sh
|
|
|
|
|
|
|
|
npm uses two configuration files, one for per-user configs, and another
|
|
|
|
for global (every-user) configs. You can view them by doing:
|
|
|
|
|
|
|
|
npm config get userconfig # defaults to ~/.npmrc
|
|
|
|
npm config get globalconfig # defaults to /usr/local/etc/npmrc
|
|
|
|
|
|
|
|
Uninstalling npm does not remove configuration files by default. You
|
|
|
|
must remove them yourself manually if you want them gone. Note that
|
|
|
|
this means that future npm installs will not remember the settings that
|
|
|
|
you have chosen.
|
|
|
|
|
|
|
|
## Using npm Programmatically
|
|
|
|
|
|
|
|
If you would like to use npm programmatically, you can do that.
|
|
|
|
It's not very well documented, but it *is* rather simple.
|
|
|
|
|
2012-08-15 05:27:28 +02:00
|
|
|
Most of the time, unless you actually want to do all the things that
|
|
|
|
npm does, you should try using one of npm's dependencies rather than
|
|
|
|
using npm itself, if possible.
|
|
|
|
|
|
|
|
Eventually, npm will be just a thin cli wrapper around the modules
|
|
|
|
that it depends on, but for now, there are some things that you must
|
|
|
|
use npm itself to do.
|
|
|
|
|
2011-11-21 18:48:45 +01:00
|
|
|
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
|
|
|
|
})
|
2014-11-05 00:08:12 +01:00
|
|
|
npm.registry.log.on("log", function (message) { .... })
|
2011-11-21 18:48:45 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
The `load` function takes an object hash of the command-line configs.
|
|
|
|
The various `npm.commands.<cmd>` functions take an **array** of
|
|
|
|
positional argument **strings**. The last argument to any
|
|
|
|
`npm.commands.<cmd>` function is a callback. Some commands take other
|
|
|
|
optional arguments. Read the source.
|
|
|
|
|
|
|
|
You cannot set configs individually for any single npm function at this
|
|
|
|
time. Since `npm` is a singleton, any call to `npm.config.set` will
|
|
|
|
change the value for *all* npm commands in that process.
|
|
|
|
|
|
|
|
See `./bin/npm-cli.js` for an example of pulling config values off of the
|
|
|
|
command line arguments using nopt. You may also want to check out `npm
|
|
|
|
help config` to learn about all the options you can set there.
|
|
|
|
|
|
|
|
## More Docs
|
|
|
|
|
2015-01-08 23:37:26 +01:00
|
|
|
Check out the [docs](https://docs.npmjs.com/),
|
|
|
|
especially the [faq](https://docs.npmjs.com/misc/faq).
|
2011-11-21 18:48:45 +01:00
|
|
|
|
|
|
|
You can use the `npm help` command to read any of them.
|
|
|
|
|
|
|
|
If you're a developer, and you want to use npm to publish your program,
|
2015-01-08 23:37:26 +01:00
|
|
|
you should [read this](https://docs.npmjs.com/misc/developers)
|
2011-11-21 18:48:45 +01:00
|
|
|
|
|
|
|
## Legal Stuff
|
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
"npm" and "The npm Registry" are owned by npm, Inc.
|
2013-09-06 02:13:50 +02:00
|
|
|
All rights reserved. See the included LICENSE file for more details.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
"Node.js" and "node" are trademarks owned by Joyent, Inc.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
Modules published on the npm registry are not officially endorsed by
|
|
|
|
npm, Inc. or the Node.js project.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
Data published to the npm registry is not part of npm itself, and is
|
|
|
|
the sole property of the publisher. While every effort is made to
|
|
|
|
ensure accountability, there is absolutely no guarantee, warrantee, or
|
|
|
|
assertion expressed or implied as to the quality, fitness for a
|
|
|
|
specific purpose, or lack of malice in any given npm package.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
If you have a complaint about a package in the public npm registry,
|
|
|
|
and cannot [resolve it with the package
|
2015-01-08 23:37:26 +01:00
|
|
|
owner](https://docs.npmjs.com/misc/disputes), please email
|
2014-02-17 05:43:16 +01:00
|
|
|
<support@npmjs.com> and explain the situation.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
Any data published to The npm Registry (including user account
|
|
|
|
information) may be removed or modified at the sole discretion of the
|
|
|
|
npm server administrators.
|
|
|
|
|
|
|
|
### In plainer english
|
|
|
|
|
|
|
|
npm is the property of npm, Inc.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
|
|
|
If you publish something, it's yours, and you are solely accountable
|
2014-02-17 05:43:16 +01:00
|
|
|
for it.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
If other people publish something, it's theirs.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
Users can publish Bad Stuff. It will be removed promptly if reported.
|
|
|
|
But there is no vetting process for published modules, and you use
|
|
|
|
them at your own risk. Please inspect the source.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2014-02-17 05:43:16 +01:00
|
|
|
If you publish Bad Stuff, we may delete it from the registry, or even
|
|
|
|
ban your account in extreme cases. So don't do that.
|
2011-11-21 18:48:45 +01:00
|
|
|
|
2011-12-01 01:45:26 +01:00
|
|
|
## BUGS
|
|
|
|
|
|
|
|
When you find issues, please report them:
|
|
|
|
|
|
|
|
* web:
|
2014-02-13 03:16:32 +01:00
|
|
|
<https://github.com/npm/npm/issues>
|
2011-12-01 01:45:26 +01:00
|
|
|
|
|
|
|
Be sure to include *all* of the output from the npm command that didn't work
|
|
|
|
as expected. The `npm-debug.log` file is also helpful to provide.
|
|
|
|
|
|
|
|
You can also look for isaacs in #node.js on irc://irc.freenode.net. He
|
|
|
|
will no doubt tell you to put the output in a gist or email.
|
|
|
|
|
2011-11-21 18:48:45 +01:00
|
|
|
## SEE ALSO
|
|
|
|
|
|
|
|
* npm(1)
|
2013-08-16 17:19:31 +02:00
|
|
|
* npm-faq(7)
|
2011-11-21 18:48:45 +01:00
|
|
|
* npm-help(1)
|
2013-08-16 17:19:31 +02:00
|
|
|
* npm-index(7)
|