1 npm-link(1) -- Symlink a package folder
2 =======================================
6 npm link (in package folder)
7 npm link [@<scope>/]<pkgname>
8 npm ln (with any of the previous argument usage)
12 Package linking is a two-step process.
14 First, `npm link` in a package folder will create a symlink in the global folder
15 `{prefix}/lib/node_modules/<package>` that links to the package where the `npm
16 link` command was executed. (see `npm-config(7)` for the value of `prefix`). It
17 will also link any bins in the package to `{prefix}/bin/{name}`.
19 Next, in some other location, `npm link package-name` will create a
20 symbolic link from globally-installed `package-name` to `node_modules/`
21 of the current folder.
23 Note that `package-name` is taken from `package.json`,
24 not from directory name.
26 The package name can be optionally prefixed with a scope. See `npm-scope(7)`.
27 The scope must be preceded by an @-symbol and followed by a slash.
29 When creating tarballs for `npm publish`, the linked packages are
30 "snapshotted" to their current state by resolving the symbolic links.
32 This is handy for installing your own stuff, so that you can work on it and
33 test it iteratively without having to continually rebuild.
37 cd ~/projects/node-redis # go into the package directory
38 npm link # creates global link
39 cd ~/projects/node-bloggy # go into some other package directory.
40 npm link redis # link-install the package
42 Now, any changes to ~/projects/node-redis will be reflected in
43 ~/projects/node-bloggy/node_modules/node-redis/. Note that the link should
44 be to the package name, not the directory name for that package.
46 You may also shortcut the two steps in one. For example, to do the
47 above use-case in a shorter way:
49 cd ~/projects/node-bloggy # go into the dir of your main project
50 npm link ../node-redis # link the dir of your dependency
52 The second line is the equivalent of doing:
54 (cd ../node-redis; npm link)
57 That is, it first creates a global link, and then links the global
58 installation target into your project's `node_modules` folder.
60 If your linked package is scoped (see `npm-scope(7)`) your link command must
61 include that scope, e.g.
63 npm link @myorg/privatepackage