node/deps/npm/man/man1/npm-link.1

101 lines
2.5 KiB
Groff
Raw Normal View History

.TH "NPM\-LINK" "1" "February 2015" "" ""
.SH "NAME"
2014-09-25 05:41:07 +08:00
\fBnpm-link\fR \- Symlink a package folder
.SH SYNOPSIS
.P
.RS 2
2014-11-05 07:08:12 +08:00
.nf
npm link (in package folder)
2014-09-25 05:41:07 +08:00
npm link [@<scope>/]<pkgname>
2013-09-06 08:13:50 +08:00
npm ln (with any of the previous argument usage)
2014-11-05 07:08:12 +08:00
.fi
2014-09-25 05:41:07 +08:00
.RE
.SH DESCRIPTION
.P
Package linking is a two\-step process\.
.P
First, \fBnpm link\fR in a package folder will create a globally\-installed
2014-09-25 05:41:07 +08:00
symbolic link from \fBprefix/package\-name\fR to the current folder (see
npm help 7 \fBnpm\-config\fR for the value of \fBprefix\fR)\.
.P
Next, in some other location, \fBnpm link package\-name\fR will create a
symlink from the local \fBnode_modules\fR folder to the global symlink\.
.P
2013-08-16 23:19:31 +08:00
Note that \fBpackage\-name\fR is taken from \fBpackage\.json\fR,
2013-05-15 05:37:59 +08:00
not from directory name\.
2014-09-25 05:41:07 +08:00
.P
The package name can be optionally prefixed with a scope\. See npm help 7 \fBnpm\-scope\fR\|\.
The scope must be preceded by an @\-symbol and followed by a slash\.
2013-05-15 05:37:59 +08:00
.P
When creating tarballs for \fBnpm publish\fR, the linked packages are
"snapshotted" to their current state by resolving the symbolic links\.
.P
2014-09-25 05:41:07 +08:00
This is handy for installing your own stuff, so that you can work on it and
test it iteratively without having to continually rebuild\.
.P
For example:
2014-09-25 05:41:07 +08:00
.P
.RS 2
2014-11-05 07:08:12 +08:00
.nf
cd ~/projects/node\-redis # go into the package directory
npm link # creates global link
cd ~/projects/node\-bloggy # go into some other package directory\.
npm link redis # link\-install the package
2014-11-05 07:08:12 +08:00
.fi
2014-09-25 05:41:07 +08:00
.RE
.P
Now, any changes to ~/projects/node\-redis will be reflected in
~/projects/node\-bloggy/node_modules/redis/
.P
You may also shortcut the two steps in one\. For example, to do the
above use\-case in a shorter way:
2014-09-25 05:41:07 +08:00
.P
.RS 2
2014-11-05 07:08:12 +08:00
.nf
cd ~/projects/node\-bloggy # go into the dir of your main project
npm link \.\./node\-redis # link the dir of your dependency
2014-11-05 07:08:12 +08:00
.fi
2014-09-25 05:41:07 +08:00
.RE
.P
The second line is the equivalent of doing:
2014-09-25 05:41:07 +08:00
.P
.RS 2
2014-11-05 07:08:12 +08:00
.nf
(cd \.\./node\-redis; npm link)
npm link redis
2014-11-05 07:08:12 +08:00
.fi
2014-09-25 05:41:07 +08:00
.RE
.P
That is, it first creates a global link, and then links the global
2014-09-25 05:41:07 +08:00
installation target into your project's \fBnode_modules\fR folder\.
.P
If your linked package is scoped (see npm help 7 \fBnpm\-scope\fR) your link command must
include that scope, e\.g\.
.P
.RS 2
2014-11-05 07:08:12 +08:00
.nf
2014-09-25 05:41:07 +08:00
npm link @myorg/privatepackage
2014-11-05 07:08:12 +08:00
.fi
2014-09-25 05:41:07 +08:00
.RE
.SH SEE ALSO
.RS 0
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 7 developers
2014-09-25 05:41:07 +08:00
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 7 faq
2014-09-25 05:41:07 +08:00
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 5 package\.json
2014-09-25 05:41:07 +08:00
.IP \(bu 2
npm help install
2014-09-25 05:41:07 +08:00
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 5 folders
2014-09-25 05:41:07 +08:00
.IP \(bu 2
npm help config
2014-09-25 05:41:07 +08:00
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 7 config
2014-09-25 05:41:07 +08:00
.IP \(bu 2
2014-09-17 06:38:50 +08:00
npm help 5 npmrc
2014-09-25 05:41:07 +08:00
.RE