| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 | .TH "NPM\-LINK" "1" "August 2021" "" "".SH "NAME"\fBnpm-link\fR \- Symlink a package folder.SS Synopsis.P.RS 2.nfnpm link (in package dir)npm link [<@scope>/]<pkg>[@<version>]alias: npm ln.fi.RE.SS Description.PPackage linking is a two\-step process\..PFirst, \fBnpm link\fP in a package folder will create a symlink in the global folder\fB{prefix}/lib/node_modules/<package>\fP that links to the package where the \fBnpmlink\fP command was executed\. It will also link any bins in the package to \fB{prefix}/bin/{name}\fP\|\.Note that \fBnpm link\fP uses the global prefix (see \fBnpm prefix \-g\fP for its value)\..PNext, in some other location, \fBnpm link package\-name\fP will create asymbolic link from globally\-installed \fBpackage\-name\fP to \fBnode_modules/\fPof the current folder\..PNote that \fBpackage\-name\fP is taken from \fBpackage\.json\fP,not from directory name\..PThe package name can be optionally prefixed with a scope\. See npm help \fBscope\fP\|\.The scope must be preceded by an @\-symbol and followed by a slash\..PWhen creating tarballs for \fBnpm publish\fP, the linked packages are"snapshotted" to their current state by resolving the symbolic links\..PThis is handy for installing your own stuff, so that you can work on it andtest it iteratively without having to continually rebuild\..PFor example:.P.RS 2.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.fi.RE.PNow, any changes to ~/projects/node\-redis will be reflected in~/projects/node\-bloggy/node_modules/node\-redis/\. Note that the link shouldbe to the package name, not the directory name for that package\..PYou may also shortcut the two steps in one\.  For example, to do theabove use\-case in a shorter way:.P.RS 2.nfcd ~/projects/node\-bloggy  # go into the dir of your main projectnpm link \.\./node\-redis     # link the dir of your dependency.fi.RE.PThe second line is the equivalent of doing:.P.RS 2.nf(cd \.\./node\-redis; npm link)npm link redis.fi.RE.PThat is, it first creates a global link, and then links the globalinstallation target into your project's \fBnode_modules\fP folder\..PNote that in this case, you are referring to the directory name, \fBnode\-redis\fP,rather than the package name \fBredis\fP\|\..PIf your linked package is scoped (see npm help \fBscope\fP) your link command must include that scope, e\.g\..P.RS 2.nfnpm link @myorg/privatepackage.fi.RE.SS See Also.RS 0.IP \(bu 2npm help developers.IP \(bu 2npm help package\.json.IP \(bu 2npm help install.IP \(bu 2npm help folders.IP \(bu 2npm help config.IP \(bu 2npm help npmrc.RE
 |