1NPM-LINK(1)                                                        NPM-LINK(1)
2
3
4

NAME

6       npm-link - Symlink a package folder
7
8   Synopsis
9         npm link (in package dir)
10         npm link [<@scope>/]<pkg>[@<version>]
11
12         alias: npm ln
13
14   Description
15       Package linking is a two-step process.
16
17       First, npm link in a package folder will create a symlink in the global
18       folder {prefix}/lib/node_modules/<package> that links  to  the  package
19       where  the npm link command was executed. It will also link any bins in
20       the package to {prefix}/bin/{name}.  Note that npm link uses the global
21       prefix (see npm prefix -g for its value).
22
23       Next,  in some other location, npm link package-name will create a sym‐
24       bolic link from globally-installed package-name to node_modules/ of the
25       current folder.
26
27       Note  that  package-name is taken from package.json, not from directory
28       name.
29
30       The package name can be optionally prefixed with a scope. See npm  help
31       scope.   The  scope  must  be preceded by an @-symbol and followed by a
32       slash.
33
34       When creating tarballs for npm publish, the linked packages are  "snap‐
35       shotted" to their current state by resolving the symbolic links.
36
37       This is handy for installing your own stuff, so that you can work on it
38       and test it iteratively without having to continually rebuild.
39
40       For example:
41
42             cd ~/projects/node-redis    # go into the package directory
43             npm link                    # creates global link
44             cd ~/projects/node-bloggy   # go into some other package directory.
45             npm link redis              # link-install the package
46
47       Now,  any  changes  to  ~/projects/node-redis  will  be  reflected   in
48       ~/projects/node-bloggy/node_modules/node-redis/.  Note  that  the  link
49       should be to the package name, not the directory name for that package.
50
51       You may also shortcut the two steps in one.  For  example,  to  do  the
52       above use-case in a shorter way:
53
54         cd ~/projects/node-bloggy  # go into the dir of your main project
55         npm link ../node-redis     # link the dir of your dependency
56
57       The second line is the equivalent of doing:
58
59         (cd ../node-redis; npm link)
60         npm link redis
61
62       That  is,  it  first  creates  a global link, and then links the global
63       installation target into your project's node_modules folder.
64
65       Note that in this case,  you  are  referring  to  the  directory  name,
66       node-redis, rather than the package name redis.
67
68       If your linked package is scoped (see npm help scope) your link command
69       must include that scope, e.g.
70
71         npm link @myorg/privatepackage
72
73   See Also
74       · npm help developers
75
76       · npm help package.json
77
78       · npm help install
79
80       · npm help folders
81
82       · npm help config
83
84       · npm help npmrc
85
86
87
88
89                                 February 2021                     NPM-LINK(1)
Impressum