mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
249 lines
7.6 KiB
249 lines
7.6 KiB
.TH "NPM" "1" "May 2015" "" ""
|
|
.SH "NAME"
|
|
\fBnpm\fR \- a JavaScript package manager
|
|
.P
|
|
Build Status \fIhttps://img\.shields\.io/travis/npm/npm/master\.svg\fR \fIhttps://travis\-ci\.org/npm/npm\fR
|
|
.SH SYNOPSIS
|
|
.P
|
|
This is just enough info to get you up and running\.
|
|
.P
|
|
Much more info available via \fBnpm help\fR once it's installed\.
|
|
.SH IMPORTANT
|
|
.P
|
|
\fBYou need node v0\.8 or higher to run this program\.\fR
|
|
.P
|
|
To install an old \fBand unsupported\fR version of npm that works on node 0\.3
|
|
and prior, clone the git repo and dig through the old tags and branches\.
|
|
.SH Super Easy Install
|
|
.P
|
|
npm comes with node \fIhttp://nodejs\.org/download/\fR now\.
|
|
.SS Windows Computers
|
|
.P
|
|
Get the MSI \fIhttp://nodejs\.org/download/\fR\|\. npm is in it\.
|
|
.SS Apple Macintosh Computers
|
|
.P
|
|
Get the pkg \fIhttp://nodejs\.org/download/\fR\|\. npm is in it\.
|
|
.SS Other Sorts of Unices
|
|
.P
|
|
Run \fBmake install\fR\|\. npm will be installed with node\.
|
|
.P
|
|
If you want a more fancy pants install (a different version, customized
|
|
paths, etc\.) then read on\.
|
|
.SH Fancy Install (Unix)
|
|
.P
|
|
There's a pretty robust install script at
|
|
https://www\.npmjs\.com/install\.sh\|\. You can download that and run it\.
|
|
.P
|
|
Here's an example using curl:
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
curl \-L https://www\.npmjs\.com/install\.sh | sh
|
|
.fi
|
|
.RE
|
|
.SS Slightly Fancier
|
|
.P
|
|
You can set any npm configuration params with that script:
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
npm_config_prefix=/some/path sh install\.sh
|
|
.fi
|
|
.RE
|
|
.P
|
|
Or, you can run it in uber\-debuggery mode:
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
npm_debug=1 sh install\.sh
|
|
.fi
|
|
.RE
|
|
.SS Even Fancier
|
|
.P
|
|
Get the code with git\. Use \fBmake\fR to build the docs and do other stuff\.
|
|
If you plan on hacking on npm, \fBmake link\fR is your friend\.
|
|
.P
|
|
If you've got the npm source code, you can also semi\-permanently set
|
|
arbitrary config keys using the \fB\|\./configure \-\-key=val \.\.\.\fR, and then
|
|
run npm commands by doing \fBnode cli\.js <cmd> <args>\fR\|\. (This is helpful
|
|
for testing, or running stuff without actually installing npm itself\.)
|
|
.SH Windows Install or Upgrade
|
|
.P
|
|
You can download a zip file from https://github\.com/npm/npm/releases, and
|
|
unpack it in the \fBnode_modules\\npm\\\fR folder inside node's installation folder\.
|
|
.P
|
|
To upgrade to npm 2, follow the Windows upgrade instructions in
|
|
the npm Troubleshooting Guide:
|
|
.P
|
|
https://github\.com/npm/npm/wiki/Troubleshooting#upgrading\-on\-windows
|
|
.P
|
|
If that's not fancy enough for you, then you can fetch the code with
|
|
git, and mess with it directly\.
|
|
.SH Installing on Cygwin
|
|
.P
|
|
No\.
|
|
.SH Uninstalling
|
|
.P
|
|
So sad to see you go\.
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
sudo npm uninstall npm \-g
|
|
.fi
|
|
.RE
|
|
.P
|
|
Or, if that fails,
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
sudo make uninstall
|
|
.fi
|
|
.RE
|
|
.SH More Severe Uninstalling
|
|
.P
|
|
Usually, the above instructions are sufficient\. That will remove
|
|
npm, but leave behind anything you've installed\.
|
|
.P
|
|
If you would like to remove all the packages that you have installed,
|
|
then you can use the \fBnpm ls\fR command to find them, and then \fBnpm rm\fR to
|
|
remove them\.
|
|
.P
|
|
To remove cruft left behind by npm 0\.x, you can use the included
|
|
\fBclean\-old\.sh\fR script file\. You can run it conveniently like this:
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
npm explore npm \-g \-\- sh scripts/clean\-old\.sh
|
|
.fi
|
|
.RE
|
|
.P
|
|
npm uses two configuration files, one for per\-user configs, and another
|
|
for global (every\-user) configs\. You can view them by doing:
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
npm config get userconfig # defaults to ~/\.npmrc
|
|
npm config get globalconfig # defaults to /usr/local/etc/npmrc
|
|
.fi
|
|
.RE
|
|
.P
|
|
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\.
|
|
.SH Using npm Programmatically
|
|
.P
|
|
If you would like to use npm programmatically, you can do that\.
|
|
It's not very well documented, but it \fIis\fR rather simple\.
|
|
.P
|
|
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\.
|
|
.P
|
|
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\.
|
|
.P
|
|
.RS 2
|
|
.nf
|
|
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\.registry\.log\.on("log", function (message) { \.\.\.\. })
|
|
})
|
|
.fi
|
|
.RE
|
|
.P
|
|
The \fBload\fR function takes an object hash of the command\-line configs\.
|
|
The various \fBnpm\.commands\.<cmd>\fR functions take an \fBarray\fR of
|
|
positional argument \fBstrings\fR\|\. The last argument to any
|
|
\fBnpm\.commands\.<cmd>\fR function is a callback\. Some commands take other
|
|
optional arguments\. Read the source\.
|
|
.P
|
|
You cannot set configs individually for any single npm function at this
|
|
time\. Since \fBnpm\fR is a singleton, any call to \fBnpm\.config\.set\fR will
|
|
change the value for \fIall\fR npm commands in that process\.
|
|
.P
|
|
See \fB\|\./bin/npm\-cli\.js\fR for an example of pulling config values off of the
|
|
command line arguments using nopt\. You may also want to check out \fBnpm
|
|
help config\fR to learn about all the options you can set there\.
|
|
.SH More Docs
|
|
.P
|
|
Check out the docs \fIhttps://docs\.npmjs\.com/\fR,
|
|
especially the faq \fIhttps://docs\.npmjs\.com/misc/faq\fR\|\.
|
|
.P
|
|
You can use the \fBnpm help\fR command to read any of them\.
|
|
.P
|
|
If you're a developer, and you want to use npm to publish your program,
|
|
you should read this \fIhttps://docs\.npmjs\.com/misc/developers\fR
|
|
.SH Legal Stuff
|
|
.P
|
|
"npm" and "The npm Registry" are owned by npm, Inc\.
|
|
All rights reserved\. See the included LICENSE file for more details\.
|
|
.P
|
|
"Node\.js" and "node" are trademarks owned by Joyent, Inc\.
|
|
.P
|
|
Modules published on the npm registry are not officially endorsed by
|
|
npm, Inc\. or the Node\.js project\.
|
|
.P
|
|
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, warranty, or
|
|
assertion expressed or implied as to the quality, fitness for a
|
|
specific purpose, or lack of malice in any given npm package\.
|
|
.P
|
|
If you have a complaint about a package in the public npm registry,
|
|
and cannot resolve it with the package
|
|
owner \fIhttps://docs\.npmjs\.com/misc/disputes\fR, please email
|
|
support@npmjs\.com and explain the situation\.
|
|
.P
|
|
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\.
|
|
.SS In plainer english
|
|
.P
|
|
npm is the property of npm, Inc\.
|
|
.P
|
|
If you publish something, it's yours, and you are solely accountable
|
|
for it\.
|
|
.P
|
|
If other people publish something, it's theirs\.
|
|
.P
|
|
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\.
|
|
.P
|
|
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\.
|
|
.SH BUGS
|
|
.P
|
|
When you find issues, please report them:
|
|
.RS 0
|
|
.IP \(bu 2
|
|
web:
|
|
https://github\.com/npm/npm/issues
|
|
|
|
.RE
|
|
.P
|
|
Be sure to include \fIall\fR of the output from the npm command that didn't work
|
|
as expected\. The \fBnpm\-debug\.log\fR file is also helpful to provide\.
|
|
.P
|
|
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\.
|
|
.SH SEE ALSO
|
|
.RS 0
|
|
.IP \(bu 2
|
|
npm help npm
|
|
.IP \(bu 2
|
|
npm help 7 faq
|
|
.IP \(bu 2
|
|
npm help help
|
|
.IP \(bu 2
|
|
npm help 7 index
|
|
|
|
.RE
|
|
|
|
|