npm-link.1 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. .TH "NPM\-LINK" "1" "October 2021" "" ""
  2. .SH "NAME"
  3. \fBnpm-link\fR \- Symlink a package folder
  4. .SS Synopsis
  5. .P
  6. .RS 2
  7. .nf
  8. npm link (in package dir)
  9. npm link [<@scope>/]<pkg>[@<version>]
  10. alias: npm ln
  11. .fi
  12. .RE
  13. .SS Description
  14. .P
  15. This is handy for installing your own stuff, so that you can work on it and
  16. test iteratively without having to continually rebuild\.
  17. .P
  18. Package linking is a two\-step process\.
  19. .P
  20. First, \fBnpm link\fP in a package folder will create a symlink in the global
  21. folder \fB{prefix}/lib/node_modules/<package>\fP that links to the package
  22. where the \fBnpm link\fP command was executed\. It will also link any bins in
  23. the package to \fB{prefix}/bin/{name}\fP\|\. Note that \fBnpm link\fP uses the global
  24. prefix (see \fBnpm prefix \-g\fP for its value)\.
  25. .P
  26. Next, in some other location, \fBnpm link package\-name\fP will create a
  27. symbolic link from globally\-installed \fBpackage\-name\fP to \fBnode_modules/\fP of
  28. the current folder\.
  29. .P
  30. Note that \fBpackage\-name\fP is taken from \fBpackage\.json\fP, \fInot\fR from the
  31. directory name\.
  32. .P
  33. The package name can be optionally prefixed with a scope\. See
  34. npm help \fBscope\fP\|\. The scope must be preceded by an @\-symbol and
  35. followed by a slash\.
  36. .P
  37. When creating tarballs for \fBnpm publish\fP, the linked packages are
  38. "snapshotted" to their current state by resolving the symbolic links, if
  39. they are included in \fBbundleDependencies\fP\|\.
  40. .P
  41. For example:
  42. .P
  43. .RS 2
  44. .nf
  45. cd ~/projects/node\-redis # go into the package directory
  46. npm link # creates global link
  47. cd ~/projects/node\-bloggy # go into some other package directory\.
  48. npm link redis # link\-install the package
  49. .fi
  50. .RE
  51. .P
  52. Now, any changes to \fB~/projects/node\-redis\fP will be reflected in
  53. \fB~/projects/node\-bloggy/node_modules/node\-redis/\fP\|\. Note that the link
  54. should be to the package name, not the directory name for that package\.
  55. .P
  56. You may also shortcut the two steps in one\. For example, to do the
  57. above use\-case in a shorter way:
  58. .P
  59. .RS 2
  60. .nf
  61. cd ~/projects/node\-bloggy # go into the dir of your main project
  62. npm link \.\./node\-redis # link the dir of your dependency
  63. .fi
  64. .RE
  65. .P
  66. The second line is the equivalent of doing:
  67. .P
  68. .RS 2
  69. .nf
  70. (cd \.\./node\-redis; npm link)
  71. npm link redis
  72. .fi
  73. .RE
  74. .P
  75. That is, it first creates a global link, and then links the global
  76. installation target into your project's \fBnode_modules\fP folder\.
  77. .P
  78. Note that in this case, you are referring to the directory name,
  79. \fBnode\-redis\fP, rather than the package name \fBredis\fP\|\.
  80. .P
  81. If your linked package is scoped (see npm help \fBscope\fP) your
  82. link command must include that scope, e\.g\.
  83. .P
  84. .RS 2
  85. .nf
  86. npm link @myorg/privatepackage
  87. .fi
  88. .RE
  89. .SS Caveat
  90. .P
  91. Note that package dependencies linked in this way are \fInot\fR saved to
  92. \fBpackage\.json\fP by default, on the assumption that the intention is to have
  93. a link stand in for a regular non\-link dependency\. Otherwise, for example,
  94. if you depend on \fBredis@^3\.0\.1\fP, and ran \fBnpm link redis\fP, it would replace
  95. the \fB^3\.0\.1\fP dependency with \fBfile:\.\./path/to/node\-redis\fP, which you
  96. probably don't want! Additionally, other users or developers on your
  97. project would run into issues if they do not have their folders set up
  98. exactly the same as yours\.
  99. .P
  100. If you are adding a \fInew\fR dependency as a link, you should add it to the
  101. relevant metadata by running \fBnpm install <dep> \-\-package\-lock\-only\fP\|\.
  102. .P
  103. If you \fIwant\fR to save the \fBfile:\fP reference in your \fBpackage\.json\fP and
  104. \fBpackage\-lock\.json\fP files, you can use \fBnpm link <dep> \-\-save\fP to do so\.
  105. .SS Workspace Usage
  106. .P
  107. \fBnpm link <pkg> \-\-workspace <name>\fP will link the relevant package as a
  108. dependency of the specified workspace(s)\. Note that It may actually be
  109. linked into the parent project's \fBnode_modules\fP folder, if there are no
  110. conflicting dependencies\.
  111. .P
  112. \fBnpm link \-\-workspace <name>\fP will create a global link to the specified
  113. workspace(s)\.
  114. .SS Configuration
  115. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS START \-\->
  116. <!\-\- automatically generated, do not edit manually \-\->
  117. <!\-\- see lib/utils/config/definitions\.js \-\->
  118. .SS \fBsave\fP
  119. .RS 0
  120. .IP \(bu 2
  121. Default: true
  122. .IP \(bu 2
  123. Type: Boolean
  124. .RE
  125. .P
  126. Save installed packages to a package\.json file as dependencies\.
  127. .P
  128. When used with the \fBnpm rm\fP command, removes the dependency from
  129. package\.json\.
  130. <!\-\- automatically generated, do not edit manually \-\->
  131. <!\-\- see lib/utils/config/definitions\.js \-\->
  132. .SS \fBsave\-exact\fP
  133. .RS 0
  134. .IP \(bu 2
  135. Default: false
  136. .IP \(bu 2
  137. Type: Boolean
  138. .RE
  139. .P
  140. Dependencies saved to package\.json will be configured with an exact version
  141. rather than using npm's default semver range operator\.
  142. <!\-\- automatically generated, do not edit manually \-\->
  143. <!\-\- see lib/utils/config/definitions\.js \-\->
  144. .SS \fBglobal\fP
  145. .RS 0
  146. .IP \(bu 2
  147. Default: false
  148. .IP \(bu 2
  149. Type: Boolean
  150. .RE
  151. .P
  152. Operates in "global" mode, so that packages are installed into the \fBprefix\fP
  153. folder instead of the current working directory\. See
  154. npm help folders for more on the differences in behavior\.
  155. .RS 0
  156. .IP \(bu 2
  157. packages are installed into the \fB{prefix}/lib/node_modules\fP folder, instead
  158. of the current working directory\.
  159. .IP \(bu 2
  160. bin files are linked to \fB{prefix}/bin\fP
  161. .IP \(bu 2
  162. man pages are linked to \fB{prefix}/share/man\fP
  163. .RE
  164. <!\-\- automatically generated, do not edit manually \-\->
  165. <!\-\- see lib/utils/config/definitions\.js \-\->
  166. .SS \fBglobal\-style\fP
  167. .RS 0
  168. .IP \(bu 2
  169. Default: false
  170. .IP \(bu 2
  171. Type: Boolean
  172. .RE
  173. .P
  174. Causes npm to install the package into your local \fBnode_modules\fP folder with
  175. the same layout it uses with the global \fBnode_modules\fP folder\. Only your
  176. direct dependencies will show in \fBnode_modules\fP and everything they depend
  177. on will be flattened in their \fBnode_modules\fP folders\. This obviously will
  178. eliminate some deduping\. If used with \fBlegacy\-bundling\fP, \fBlegacy\-bundling\fP
  179. will be preferred\.
  180. <!\-\- automatically generated, do not edit manually \-\->
  181. <!\-\- see lib/utils/config/definitions\.js \-\->
  182. .SS \fBlegacy\-bundling\fP
  183. .RS 0
  184. .IP \(bu 2
  185. Default: false
  186. .IP \(bu 2
  187. Type: Boolean
  188. .RE
  189. .P
  190. Causes npm to install the package such that versions of npm prior to 1\.4,
  191. such as the one included with node 0\.8, can install the package\. This
  192. eliminates all automatic deduping\. If used with \fBglobal\-style\fP this option
  193. will be preferred\.
  194. <!\-\- automatically generated, do not edit manually \-\->
  195. <!\-\- see lib/utils/config/definitions\.js \-\->
  196. .SS \fBstrict\-peer\-deps\fP
  197. .RS 0
  198. .IP \(bu 2
  199. Default: false
  200. .IP \(bu 2
  201. Type: Boolean
  202. .RE
  203. .P
  204. If set to \fBtrue\fP, and \fB\-\-legacy\-peer\-deps\fP is not set, then \fIany\fR
  205. conflicting \fBpeerDependencies\fP will be treated as an install failure, even
  206. if npm could reasonably guess the appropriate resolution based on non\-peer
  207. dependency relationships\.
  208. .P
  209. By default, conflicting \fBpeerDependencies\fP deep in the dependency graph will
  210. be resolved using the nearest non\-peer dependency specification, even if
  211. doing so will result in some packages receiving a peer dependency outside
  212. the range set in their package's \fBpeerDependencies\fP object\.
  213. .P
  214. When such and override is performed, a warning is printed, explaining the
  215. conflict and the packages involved\. If \fB\-\-strict\-peer\-deps\fP is set, then
  216. this warning is treated as a failure\.
  217. <!\-\- automatically generated, do not edit manually \-\->
  218. <!\-\- see lib/utils/config/definitions\.js \-\->
  219. .SS \fBpackage\-lock\fP
  220. .RS 0
  221. .IP \(bu 2
  222. Default: true
  223. .IP \(bu 2
  224. Type: Boolean
  225. .RE
  226. .P
  227. If set to false, then ignore \fBpackage\-lock\.json\fP files when installing\. This
  228. will also prevent \fIwriting\fR \fBpackage\-lock\.json\fP if \fBsave\fP is true\.
  229. .P
  230. When package package\-locks are disabled, automatic pruning of extraneous
  231. modules will also be disabled\. To remove extraneous modules with
  232. package\-locks disabled use \fBnpm prune\fP\|\.
  233. <!\-\- automatically generated, do not edit manually \-\->
  234. <!\-\- see lib/utils/config/definitions\.js \-\->
  235. .SS \fBomit\fP
  236. .RS 0
  237. .IP \(bu 2
  238. Default: 'dev' if the \fBNODE_ENV\fP environment variable is set to
  239. \|'production', otherwise empty\.
  240. .IP \(bu 2
  241. Type: "dev", "optional", or "peer" (can be set multiple times)
  242. .RE
  243. .P
  244. Dependency types to omit from the installation tree on disk\.
  245. .P
  246. Note that these dependencies \fIare\fR still resolved and added to the
  247. \fBpackage\-lock\.json\fP or \fBnpm\-shrinkwrap\.json\fP file\. They are just not
  248. physically installed on disk\.
  249. .P
  250. If a package type appears in both the \fB\-\-include\fP and \fB\-\-omit\fP lists, then
  251. it will be included\.
  252. .P
  253. If the resulting omit list includes \fB\|'dev'\fP, then the \fBNODE_ENV\fP environment
  254. variable will be set to \fB\|'production'\fP for all lifecycle scripts\.
  255. <!\-\- automatically generated, do not edit manually \-\->
  256. <!\-\- see lib/utils/config/definitions\.js \-\->
  257. .SS \fBignore\-scripts\fP
  258. .RS 0
  259. .IP \(bu 2
  260. Default: false
  261. .IP \(bu 2
  262. Type: Boolean
  263. .RE
  264. .P
  265. If true, npm does not run scripts specified in package\.json files\.
  266. .P
  267. Note that commands explicitly intended to run a particular script, such as
  268. \fBnpm start\fP, \fBnpm stop\fP, \fBnpm restart\fP, \fBnpm test\fP, and \fBnpm run\-script\fP
  269. will still run their intended script if \fBignore\-scripts\fP is set, but they
  270. will \fInot\fR run any pre\- or post\-scripts\.
  271. <!\-\- automatically generated, do not edit manually \-\->
  272. <!\-\- see lib/utils/config/definitions\.js \-\->
  273. .SS \fBaudit\fP
  274. .RS 0
  275. .IP \(bu 2
  276. Default: true
  277. .IP \(bu 2
  278. Type: Boolean
  279. .RE
  280. .P
  281. When "true" submit audit reports alongside the current npm command to the
  282. default registry and all registries configured for scopes\. See the
  283. documentation for npm help \fBaudit\fP for details on what is
  284. submitted\.
  285. <!\-\- automatically generated, do not edit manually \-\->
  286. <!\-\- see lib/utils/config/definitions\.js \-\->
  287. .SS \fBbin\-links\fP
  288. .RS 0
  289. .IP \(bu 2
  290. Default: true
  291. .IP \(bu 2
  292. Type: Boolean
  293. .RE
  294. .P
  295. Tells npm to create symlinks (or \fB\|\.cmd\fP shims on Windows) for package
  296. executables\.
  297. .P
  298. Set to false to have it not do this\. This can be used to work around the
  299. fact that some file systems don't support symlinks, even on ostensibly Unix
  300. systems\.
  301. <!\-\- automatically generated, do not edit manually \-\->
  302. <!\-\- see lib/utils/config/definitions\.js \-\->
  303. .SS \fBfund\fP
  304. .RS 0
  305. .IP \(bu 2
  306. Default: true
  307. .IP \(bu 2
  308. Type: Boolean
  309. .RE
  310. .P
  311. When "true" displays the message at the end of each \fBnpm install\fP
  312. acknowledging the number of dependencies looking for funding\. See npm help \fBnpm
  313. fund\fP for details\.
  314. <!\-\- automatically generated, do not edit manually \-\->
  315. <!\-\- see lib/utils/config/definitions\.js \-\->
  316. .SS \fBdry\-run\fP
  317. .RS 0
  318. .IP \(bu 2
  319. Default: false
  320. .IP \(bu 2
  321. Type: Boolean
  322. .RE
  323. .P
  324. Indicates that you don't want npm to make any changes and that it should
  325. only report what it would have done\. This can be passed into any of the
  326. commands that modify your local installation, eg, \fBinstall\fP, \fBupdate\fP,
  327. \fBdedupe\fP, \fBuninstall\fP, as well as \fBpack\fP and \fBpublish\fP\|\.
  328. .P
  329. Note: This is NOT honored by other network related commands, eg \fBdist\-tags\fP,
  330. \fBowner\fP, etc\.
  331. <!\-\- automatically generated, do not edit manually \-\->
  332. <!\-\- see lib/utils/config/definitions\.js \-\->
  333. .SS \fBworkspace\fP
  334. .RS 0
  335. .IP \(bu 2
  336. Default:
  337. .IP \(bu 2
  338. Type: String (can be set multiple times)
  339. .RE
  340. .P
  341. Enable running a command in the context of the configured workspaces of the
  342. current project while filtering by running only the workspaces defined by
  343. this configuration option\.
  344. .P
  345. Valid values for the \fBworkspace\fP config are either:
  346. .RS 0
  347. .IP \(bu 2
  348. Workspace names
  349. .IP \(bu 2
  350. Path to a workspace directory
  351. .IP \(bu 2
  352. Path to a parent workspace directory (will result in selecting all
  353. workspaces within that folder)
  354. .RE
  355. .P
  356. When set for the \fBnpm init\fP command, this may be set to the folder of a
  357. workspace which does not yet exist, to create the folder and set it up as a
  358. brand new workspace within the project\.
  359. .P
  360. This value is not exported to the environment for child processes\.
  361. <!\-\- automatically generated, do not edit manually \-\->
  362. <!\-\- see lib/utils/config/definitions\.js \-\->
  363. .SS \fBworkspaces\fP
  364. .RS 0
  365. .IP \(bu 2
  366. Default: null
  367. .IP \(bu 2
  368. Type: null or Boolean
  369. .RE
  370. .P
  371. Set to true to run the command in the context of \fBall\fR configured
  372. workspaces\.
  373. .P
  374. Explicitly setting this to false will cause commands like \fBinstall\fP to
  375. ignore workspaces altogether\. When not set explicitly:
  376. .RS 0
  377. .IP \(bu 2
  378. Commands that operate on the \fBnode_modules\fP tree (install, update, etc\.)
  379. will link workspaces into the \fBnode_modules\fP folder\. \- Commands that do
  380. other things (test, exec, publish, etc\.) will operate on the root project,
  381. \fIunless\fR one or more workspaces are specified in the \fBworkspace\fP config\.
  382. .RE
  383. .P
  384. This value is not exported to the environment for child processes\.
  385. <!\-\- automatically generated, do not edit manually \-\->
  386. <!\-\- see lib/utils/config/definitions\.js \-\->
  387. .SS \fBinclude\-workspace\-root\fP
  388. .RS 0
  389. .IP \(bu 2
  390. Default: false
  391. .IP \(bu 2
  392. Type: Boolean
  393. .RE
  394. .P
  395. Include the workspace root when workspaces are enabled for a command\.
  396. .P
  397. When false, specifying individual workspaces via the \fBworkspace\fP config, or
  398. all workspaces via the \fBworkspaces\fP flag, will cause npm to operate only on
  399. the specified workspaces, and not on the root project\.
  400. <!\-\- automatically generated, do not edit manually \-\->
  401. <!\-\- see lib/utils/config/definitions\.js \-\->
  402. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS END \-\->
  403. .SS See Also
  404. .RS 0
  405. .IP \(bu 2
  406. npm help developers
  407. .IP \(bu 2
  408. npm help package\.json
  409. .IP \(bu 2
  410. npm help install
  411. .IP \(bu 2
  412. npm help folders
  413. .IP \(bu 2
  414. npm help config
  415. .IP \(bu 2
  416. npm help npmrc
  417. .RE