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

NAME

6       npm-link - Symlink a package folder
7

SYNOPSIS

9         npm link (in package dir)
10         npm link [<@scope>/]<pkg>[@<version>]
11
12         alias: npm ln
13

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. (see npm help 7 npm-config for
20       the value of prefix). It will also link any  bins  in  the  package  to
21       {prefix}/bin/{name}.
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       7 npm-scope.  The scope must be preceded by an @-symbol and followed by
32       a 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 7 npm-scope) your link
69       command must include that scope, e.g.
70
71         npm link @myorg/privatepackage
72

SEE ALSO

74       · npm help 7 developers
75
76       · npm help 5 package.json
77
78       · npm help install
79
80       · npm help 5 folders
81
82       · npm help config
83
84       · npm help 7 config
85
86       · npm help 5 npmrc
87
88
89
90
91
92                                 October 2019                      NPM-LINK(1)
Impressum