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.
256 lines
8.1 KiB
256 lines
8.1 KiB
.TH "NPM" "1" "July 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\fP 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\fP\|\. 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\fP to build the docs and do other stuff\.
|
|
If you plan on hacking on npm, \fBmake link\fP 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 \.\.\.\fP, and then
|
|
run npm commands by doing \fBnode cli\.js <cmd> <args>\fP\|\. (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\\\fP 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\fP command to find them, and then \fBnpm rm\fP to
|
|
remove them\.
|
|
.P
|
|
To remove cruft left behind by npm 0\.x, you can use the included
|
|
\fBclean\-old\.sh\fP 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
|
|
Although npm can be used programmatically, its API is meant for use by the CLI
|
|
\fIonly\fR, and no guarantees are made regarding its fitness for any other purpose\.
|
|
If you want to use npm to reliably perform some task, the safest thing to do is
|
|
to invoke the desired \fBnpm\fP command with appropriate arguments\.
|
|
.P
|
|
The semantic version of npm refers to the CLI itself, rather than the
|
|
underlying API\. \fIThe internal API is not guaranteed to remain stable even when
|
|
npm's version indicates no breaking changes have been made according to
|
|
semver\.\fR
|
|
.P
|
|
If you \fIstill\fR would like to use npm programmatically, it's \fIpossible\fR\|\. The API
|
|
isn't very well documented, but it \fIis\fR rather simple\.
|
|
.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 only the CLI can do\. You
|
|
should try using one of npm's dependencies first, and only use the API if what
|
|
you're trying to do is only supported by npm itself\.
|
|
.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\fP function takes an object hash of the command\-line configs\.
|
|
The various \fBnpm\.commands\.<cmd>\fP functions take an \fBarray\fR of
|
|
positional argument \fBstrings\fR\|\. The last argument to any
|
|
\fBnpm\.commands\.<cmd>\fP 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\fP is a singleton, any call to \fBnpm\.config\.set\fP will
|
|
change the value for \fIall\fR npm commands in that process\.
|
|
.P
|
|
See \fB\|\./bin/npm\-cli\.js\fP 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\fP 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\fP 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\fP 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
|
|
|
|
|