\fBnpm-folders\fR\-\- Folder Structures Used by npm
.
.SH"DESCRIPTION"
npm puts various things on your computer\. That\'s its job\.
.
.P
This document will tell you what it puts where\.
.
.SS"tl;dr"
.
.IP"\(bu"4
Local install (default): puts stuff in \fB\|\./node_modules\fR of the current
package root\.
.
.IP"\(bu"4
Global install (with \fB\-g\fR): puts stuff in /usr/local or wherever node
is installed\.
.
.IP"\(bu"4
Install it \fBlocally\fR if you\'re going to \fBrequire()\fR it\.
.
.IP"\(bu"4
Install it \fBglobally\fR if you\'re going to run it on the command line\.
.
.IP"\(bu"4
If you need both, then install it in both places, or use \fBnpm link\fR\|\.
.
.IP""0
.
.SS"prefix Configuration"
The \fBprefix\fR config defaults to the location where node is installed\.
On most systems, this is \fB/usr/local\fR, and most of the time is the same
as node\'s \fBprocess\.installPrefix\fR\|\.
.
.P
On windows, this is the exact location of the node\.exe binary\. On Unix
systems, it\'s one level up, since node is typically installed at \fB{prefix}/bin/node\fR rather than \fB{prefix}/node\.exe\fR\|\.
.
.P
When the \fBglobal\fR flag is set, npm installs things into this prefix\.
When it is not set, it uses the root of the current package, or the
current working directory if not in a package already\.
.
.SS"Node Modules"
Packages are dropped into the \fBnode_modules\fR folder under the \fBprefix\fR\|\.
When installing locally, this means that you can \fBrequire("packagename")\fR to load its main module, or \fBrequire("packagename/lib/path/to/sub/module")\fR to load other modules\.
.
.P
Global installs on Unix systems go to \fB{prefix}/lib/node_modules\fR\|\.
Global installs on Windows go to \fB{prefix}/node_modules\fR (that is, no \fBlib\fR folder\.)
.
.P
If you wish to \fBrequire()\fR a package, then install it locally\.
.
.SS"Executables"
When in global mode, executables are linked into \fB{prefix}/bin\fR on Unix,
or directly into \fB{prefix}\fR on Windows\.
.
.P
When in local mode, executables are linked into \fB\|\./node_modules/\.bin\fR so that they can be made available to scripts run
through npm\. (For example, so that a test runner will be in the path
when you run \fBnpm test\fR\|\.)
.
.SS"Man Pages"
When in global mode, man pages are linked into \fB{prefix}/share/man\fR\|\.