Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

545 lines
19 KiB

  1. .TH "NPM\-INSTALL" "1" "August 2018" "" ""
  2. .SH "NAME"
  3. \fBnpm-install\fR \- Install a package
  4. .SH SYNOPSIS
  5. .P
  6. .RS 2
  7. .nf
  8. npm install (with no args, in package dir)
  9. npm install [<@scope>/]<name>
  10. npm install [<@scope>/]<name>@<tag>
  11. npm install [<@scope>/]<name>@<version>
  12. npm install [<@scope>/]<name>@<version range>
  13. npm install <git\-host>:<git\-user>/<repo\-name>
  14. npm install <git repo url>
  15. npm install <tarball file>
  16. npm install <tarball url>
  17. npm install <folder>
  18. alias: npm i
  19. common options: [\-P|\-\-save\-prod|\-D|\-\-save\-dev|\-O|\-\-save\-optional] [\-E|\-\-save\-exact] [\-B|\-\-save\-bundle] [\-\-no\-save] [\-\-dry\-run]
  20. .fi
  21. .RE
  22. .SH DESCRIPTION
  23. .P
  24. This command installs a package, and any packages that it depends on\. If the
  25. package has a package\-lock or shrinkwrap file, the installation of dependencies
  26. will be driven by that, with an \fBnpm\-shrinkwrap\.json\fP taking precedence if both
  27. files exist\. See npm help 5 package\-lock\.json and npm help shrinkwrap\.
  28. .P
  29. A \fBpackage\fP is:
  30. .RS 0
  31. .IP \(bu 2
  32. a) a folder containing a program described by a npm help 5 \fBpackage\.json\fP file
  33. .IP \(bu 2
  34. b) a gzipped tarball containing (a)
  35. .IP \(bu 2
  36. c) a url that resolves to (b)
  37. .IP \(bu 2
  38. d) a \fB<name>@<version>\fP that is published on the registry (see npm help 7 \fBnpm\-registry\fP) with (c)
  39. .IP \(bu 2
  40. e) a \fB<name>@<tag>\fP (see npm help \fBnpm\-dist\-tag\fP) that points to (d)
  41. .IP \(bu 2
  42. f) a \fB<name>\fP that has a "latest" tag satisfying (e)
  43. .IP \(bu 2
  44. g) a \fB<git remote url>\fP that resolves to (a)
  45. .RE
  46. .P
  47. Even if you never publish your package, you can still get a lot of
  48. benefits of using npm if you just want to write a node program (a), and
  49. perhaps if you also want to be able to easily install it elsewhere
  50. after packing it up into a tarball (b)\.
  51. .RS 0
  52. .IP \(bu 2
  53. \fBnpm install\fP (in package directory, no arguments):
  54. Install the dependencies in the local node_modules folder\.
  55. In global mode (ie, with \fB\-g\fP or \fB\-\-global\fP appended to the command),
  56. it installs the current package context (ie, the current working
  57. directory) as a global package\.
  58. By default, \fBnpm install\fP will install all modules listed as dependencies
  59. in npm help 5 \fBpackage\.json\fP\|\.
  60. With the \fB\-\-production\fP flag (or when the \fBNODE_ENV\fP environment variable
  61. is set to \fBproduction\fP), npm will not install modules listed in
  62. \fBdevDependencies\fP\|\.
  63. .QP
  64. NOTE: The \fB\-\-production\fP flag has no particular meaning when adding a
  65. dependency to a project\.
  66. .
  67. .IP \(bu 2
  68. \fBnpm install <folder>\fP:
  69. Install the package in the directory as a symlink in the current project\.
  70. Its dependencies will be installed before it's linked\. If \fB<folder>\fP sits
  71. inside the root of your project, its dependencies may be hoisted to the
  72. toplevel \fBnode_modules\fP as they would for other types of dependencies\.
  73. .IP \(bu 2
  74. \fBnpm install <tarball file>\fP:
  75. Install a package that is sitting on the filesystem\. Note: if you just want
  76. to link a dev directory into your npm root, you can do this more easily by
  77. using \fBnpm link\fP\|\.
  78. Tarball requirements:
  79. .RS 0
  80. .IP \(bu 2
  81. The filename \fImust\fR use \fB\|\.tar\fP, \fB\|\.tar\.gz\fP, or \fB\|\.tgz\fP as
  82. the extension\.
  83. .IP \(bu 2
  84. The package contents should reside in a subfolder inside the tarball (usually it is called \fBpackage/\fP)\. npm strips one directory layer when installing the package (an equivalent of \fBtar x \-\-strip\-components=1\fP is run)\.
  85. .IP \(bu 2
  86. The package must contain a \fBpackage\.json\fP file with \fBname\fP and \fBversion\fP properties\.
  87. Example:
  88. .P
  89. .RS 2
  90. .nf
  91. npm install \./package\.tgz
  92. .fi
  93. .RE
  94. .RE
  95. .IP \(bu 2
  96. \fBnpm install <tarball url>\fP:
  97. Fetch the tarball url, and then install it\. In order to distinguish between
  98. this and other options, the argument must start with "http://" or "https://"
  99. Example:
  100. .P
  101. .RS 2
  102. .nf
  103. npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
  104. .fi
  105. .RE
  106. .IP \(bu 2
  107. \fBnpm install [<@scope>/]<name>\fP:
  108. Do a \fB<name>@<tag>\fP install, where \fB<tag>\fP is the "tag" config\. (See
  109. npm help 7 \fBnpm\-config\fP\|\. The config's default value is \fBlatest\fP\|\.)
  110. In most cases, this will install the version of the modules tagged as
  111. \fBlatest\fP on the npm registry\.
  112. Example:
  113. .P
  114. .RS 2
  115. .nf
  116. npm install sax
  117. .fi
  118. .RE
  119. \fBnpm install\fP saves any specified packages into \fBdependencies\fP by default\.
  120. Additionally, you can control where and how they get saved with some
  121. additional flags:
  122. .RS 0
  123. .IP \(bu 2
  124. \fB\-P, \-\-save\-prod\fP: Package will appear in your \fBdependencies\fP\|\. This is the
  125. .P
  126. .RS 2
  127. .nf
  128. default unless `\-D` or `\-O` are present\.
  129. .fi
  130. .RE
  131. .IP \(bu 2
  132. \fB\-D, \-\-save\-dev\fP: Package will appear in your \fBdevDependencies\fP\|\.
  133. .IP \(bu 2
  134. \fB\-O, \-\-save\-optional\fP: Package will appear in your \fBoptionalDependencies\fP\|\.
  135. .IP \(bu 2
  136. \fB\-\-no\-save\fP: Prevents saving to \fBdependencies\fP\|\.
  137. When using any of the above options to save dependencies to your
  138. package\.json, there are two additional, optional flags:
  139. .IP \(bu 2
  140. \fB\-E, \-\-save\-exact\fP: Saved dependencies will be configured with an
  141. exact version rather than using npm's default semver range
  142. operator\.
  143. .IP \(bu 2
  144. \fB\-B, \-\-save\-bundle\fP: Saved dependencies will also be added to your \fBbundleDependencies\fP list\.
  145. Further, if you have an \fBnpm\-shrinkwrap\.json\fP or \fBpackage\-lock\.json\fP then it
  146. will be updated as well\.
  147. \fB<scope>\fP is optional\. The package will be downloaded from the registry
  148. associated with the specified scope\. If no registry is associated with
  149. the given scope the default registry is assumed\. See npm help 7 \fBnpm\-scope\fP\|\.
  150. Note: if you do not include the @\-symbol on your scope name, npm will
  151. interpret this as a GitHub repository instead, see below\. Scopes names
  152. must also be followed by a slash\.
  153. Examples:
  154. .P
  155. .RS 2
  156. .nf
  157. npm install sax
  158. npm install githubname/reponame
  159. npm install @myorg/privatepackage
  160. npm install node\-tap \-\-save\-dev
  161. npm install dtrace\-provider \-\-save\-optional
  162. npm install readable\-stream \-\-save\-exact
  163. npm install ansi\-regex \-\-save\-bundle
  164. .fi
  165. .RE
  166. .RE
  167. .RE
  168. .P
  169. .RS 2
  170. .nf
  171. **Note**: If there is a file or folder named `<name>` in the current
  172. working directory, then it will try to install that, and only try to
  173. fetch the package by name if it is not valid\.
  174. .fi
  175. .RE
  176. .RS 0
  177. .IP \(bu 2
  178. \fBnpm install [<@scope>/]<name>@<tag>\fP:
  179. Install the version of the package that is referenced by the specified tag\.
  180. If the tag does not exist in the registry data for that package, then this
  181. will fail\.
  182. Example:
  183. .P
  184. .RS 2
  185. .nf
  186. npm install sax@latest
  187. npm install @myorg/mypackage@latest
  188. .fi
  189. .RE
  190. .IP \(bu 2
  191. \fBnpm install [<@scope>/]<name>@<version>\fP:
  192. Install the specified version of the package\. This will fail if the
  193. version has not been published to the registry\.
  194. Example:
  195. .P
  196. .RS 2
  197. .nf
  198. npm install sax@0\.1\.1
  199. npm install @myorg/privatepackage@1\.5\.0
  200. .fi
  201. .RE
  202. .IP \(bu 2
  203. \fBnpm install [<@scope>/]<name>@<version range>\fP:
  204. Install a version of the package matching the specified version range\. This
  205. will follow the same rules for resolving dependencies described in npm help 5 \fBpackage\.json\fP\|\.
  206. Note that most version ranges must be put in quotes so that your shell will
  207. treat it as a single argument\.
  208. Example:
  209. .P
  210. .RS 2
  211. .nf
  212. npm install sax@">=0\.1\.0 <0\.2\.0"
  213. npm install @myorg/privatepackage@">=0\.1\.0 <0\.2\.0"
  214. .fi
  215. .RE
  216. .IP \(bu 2
  217. \fBnpm install <git remote url>\fP:
  218. Installs the package from the hosted git provider, cloning it with \fBgit\fP\|\.
  219. For a full git remote url, only that URL will be attempted\.
  220. .P
  221. .RS 2
  222. .nf
  223. <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit\-ish> | #semver:<semver>]
  224. .fi
  225. .RE
  226. \fB<protocol>\fP is one of \fBgit\fP, \fBgit+ssh\fP, \fBgit+http\fP, \fBgit+https\fP, or
  227. \fBgit+file\fP\|\.
  228. If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
  229. commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
  230. be any valid semver range or exact version, and npm will look for any tags
  231. or refs matching that range in the remote repository, much as it would for a
  232. registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
  233. specified, then \fBmaster\fP is used\.
  234. If the repository makes use of submodules, those submodules will be cloned
  235. as well\.
  236. If the package being installed contains a \fBprepare\fP script, its
  237. \fBdependencies\fP and \fBdevDependencies\fP will be installed, and the prepare
  238. script will be run, before the package is packaged and installed\.
  239. The following git environment variables are recognized by npm and will be
  240. added to the environment when running git:
  241. .RS 0
  242. .IP \(bu 2
  243. \fBGIT_ASKPASS\fP
  244. .IP \(bu 2
  245. \fBGIT_EXEC_PATH\fP
  246. .IP \(bu 2
  247. \fBGIT_PROXY_COMMAND\fP
  248. .IP \(bu 2
  249. \fBGIT_SSH\fP
  250. .IP \(bu 2
  251. \fBGIT_SSH_COMMAND\fP
  252. .IP \(bu 2
  253. \fBGIT_SSL_CAINFO\fP
  254. .IP \(bu 2
  255. \fBGIT_SSL_NO_VERIFY\fP
  256. See the git man page for details\.
  257. Examples:
  258. .P
  259. .RS 2
  260. .nf
  261. npm install git+ssh://git@github\.com:npm/cli\.git#v1\.0\.27
  262. npm install git+ssh://git@github\.com:npm/cli#semver:^5\.0
  263. npm install git+https://isaacs@github\.com/npm/cli\.git
  264. npm install git://github\.com/npm/cli\.git#v1\.0\.27
  265. GIT_SSH_COMMAND='ssh \-i ~/\.ssh/custom_ident' npm install git+ssh://git@github\.com:npm/cli\.git
  266. .fi
  267. .RE
  268. .RE
  269. .IP \(bu 2
  270. \fBnpm install <githubname>/<githubrepo>[#<commit\-ish>]\fP:
  271. .IP \(bu 2
  272. \fBnpm install github:<githubname>/<githubrepo>[#<commit\-ish>]\fP:
  273. Install the package at \fBhttps://github\.com/githubname/githubrepo\fP by
  274. attempting to clone it using \fBgit\fP\|\.
  275. If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
  276. commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
  277. be any valid semver range or exact version, and npm will look for any tags
  278. or refs matching that range in the remote repository, much as it would for a
  279. registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
  280. specified, then \fBmaster\fP is used\.
  281. As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
  282. be installed if the package has a \fBprepare\fP script, before the package is
  283. done installing\.
  284. Examples:
  285. .P
  286. .RS 2
  287. .nf
  288. npm install mygithubuser/myproject
  289. npm install github:mygithubuser/myproject
  290. .fi
  291. .RE
  292. .IP \(bu 2
  293. \fBnpm install gist:[<githubname>/]<gistID>[#<commit\-ish>|#semver:<semver>]\fP:
  294. Install the package at \fBhttps://gist\.github\.com/gistID\fP by attempting to
  295. clone it using \fBgit\fP\|\. The GitHub username associated with the gist is
  296. optional and will not be saved in \fBpackage\.json\fP\|\.
  297. As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
  298. be installed if the package has a \fBprepare\fP script, before the package is
  299. done installing\.
  300. Example:
  301. .P
  302. .RS 2
  303. .nf
  304. npm install gist:101a11beef
  305. .fi
  306. .RE
  307. .IP \(bu 2
  308. \fBnpm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit\-ish>]\fP:
  309. Install the package at \fBhttps://bitbucket\.org/bitbucketname/bitbucketrepo\fP
  310. by attempting to clone it using \fBgit\fP\|\.
  311. If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
  312. commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
  313. be any valid semver range or exact version, and npm will look for any tags
  314. or refs matching that range in the remote repository, much as it would for a
  315. registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
  316. specified, then \fBmaster\fP is used\.
  317. As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
  318. be installed if the package has a \fBprepare\fP script, before the package is
  319. done installing\.
  320. Example:
  321. .P
  322. .RS 2
  323. .nf
  324. npm install bitbucket:mybitbucketuser/myproject
  325. .fi
  326. .RE
  327. .IP \(bu 2
  328. \fBnpm install gitlab:<gitlabname>/<gitlabrepo>[#<commit\-ish>]\fP:
  329. Install the package at \fBhttps://gitlab\.com/gitlabname/gitlabrepo\fP
  330. by attempting to clone it using \fBgit\fP\|\.
  331. If \fB#<commit\-ish>\fP is provided, it will be used to clone exactly that
  332. commit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP can
  333. be any valid semver range or exact version, and npm will look for any tags
  334. or refs matching that range in the remote repository, much as it would for a
  335. registry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP is
  336. specified, then \fBmaster\fP is used\.
  337. As with regular git dependencies, \fBdependencies\fP and \fBdevDependencies\fP will
  338. be installed if the package has a \fBprepare\fP script, before the package is
  339. done installing\.
  340. Example:
  341. .P
  342. .RS 2
  343. .nf
  344. npm install gitlab:mygitlabuser/myproject
  345. npm install gitlab:myusr/myproj#semver:^5\.0
  346. .fi
  347. .RE
  348. .RE
  349. .P
  350. You may combine multiple arguments, and even multiple types of arguments\.
  351. For example:
  352. .P
  353. .RS 2
  354. .nf
  355. npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
  356. .fi
  357. .RE
  358. .P
  359. The \fB\-\-tag\fP argument will apply to all of the specified install targets\. If a
  360. tag with the given name exists, the tagged version is preferred over newer
  361. versions\.
  362. .P
  363. The \fB\-\-dry\-run\fP argument will report in the usual way what the install would
  364. have done without actually installing anything\.
  365. .P
  366. The \fB\-\-package\-lock\-only\fP argument will only update the \fBpackage\-lock\.json\fP,
  367. instead of checking \fBnode_modules\fP and downloading dependencies\.
  368. .P
  369. The \fB\-f\fP or \fB\-\-force\fP argument will force npm to fetch remote resources even if a
  370. local copy exists on disk\.
  371. .P
  372. .RS 2
  373. .nf
  374. npm install sax \-\-force
  375. .fi
  376. .RE
  377. .P
  378. The \fB\-g\fP or \fB\-\-global\fP argument will cause npm to install the package globally
  379. rather than locally\. See npm help 5 \fBnpm\-folders\fP\|\.
  380. .P
  381. The \fB\-\-global\-style\fP argument will cause npm to install the package into
  382. your local \fBnode_modules\fP folder with the same layout it uses with the
  383. global \fBnode_modules\fP folder\. Only your direct dependencies will show in
  384. \fBnode_modules\fP and everything they depend on will be flattened in their
  385. \fBnode_modules\fP folders\. This obviously will eliminate some deduping\.
  386. .P
  387. The \fB\-\-ignore\-scripts\fP argument will cause npm to not execute any
  388. scripts defined in the package\.json\. See npm help 7 \fBnpm\-scripts\fP\|\.
  389. .P
  390. The \fB\-\-legacy\-bundling\fP argument will cause npm to install the package such
  391. that versions of npm prior to 1\.4, such as the one included with node 0\.8,
  392. can install the package\. This eliminates all automatic deduping\.
  393. .P
  394. The \fB\-\-link\fP argument will cause npm to link global installs into the
  395. local space in some cases\.
  396. .P
  397. The \fB\-\-no\-bin\-links\fP argument will prevent npm from creating symlinks for
  398. any binaries the package might contain\.
  399. .P
  400. The \fB\-\-no\-optional\fP argument will prevent optional dependencies from
  401. being installed\.
  402. .P
  403. The \fB\-\-no\-shrinkwrap\fP argument, which will ignore an available
  404. package lock or shrinkwrap file and use the package\.json instead\.
  405. .P
  406. The \fB\-\-no\-package\-lock\fP argument will prevent npm from creating a
  407. \fBpackage\-lock\.json\fP file\. When running with package\-lock's disabled npm
  408. will not automatically prune your node modules when installing\.
  409. .P
  410. The \fB\-\-nodedir=/path/to/node/source\fP argument will allow npm to find the
  411. node source code so that npm can compile native modules\.
  412. .P
  413. The \fB\-\-only={prod[uction]|dev[elopment]}\fP argument will cause either only
  414. \fBdevDependencies\fP or only non\-\fBdevDependencies\fP to be installed regardless of the \fBNODE_ENV\fP\|\.
  415. .P
  416. The \fB\-\-no\-audit\fP argument can be used to disable sending of audit reports to
  417. the configured registries\. See npm help \fBnpm\-audit\fP for details on what is sent\.
  418. .P
  419. See npm help 7 \fBnpm\-config\fP\|\. Many of the configuration params have some
  420. effect on installation, since that's most of what npm does\.
  421. .SH ALGORITHM
  422. .P
  423. To install a package, npm uses the following algorithm:
  424. .P
  425. .RS 2
  426. .nf
  427. load the existing node_modules tree from disk
  428. clone the tree
  429. fetch the package\.json and assorted metadata and add it to the clone
  430. walk the clone and add any missing dependencies
  431. dependencies will be added as close to the top as is possible
  432. without breaking any other modules
  433. compare the original tree with the cloned tree and make a list of
  434. actions to take to convert one to the other
  435. execute all of the actions, deepest first
  436. kinds of actions are install, update, remove and move
  437. .fi
  438. .RE
  439. .P
  440. For this \fBpackage{dep}\fP structure: \fBA{B,C}, B{C}, C{D}\fP,
  441. this algorithm produces:
  442. .P
  443. .RS 2
  444. .nf
  445. A
  446. +\-\- B
  447. +\-\- C
  448. +\-\- D
  449. .fi
  450. .RE
  451. .P
  452. That is, the dependency from B to C is satisfied by the fact that A
  453. already caused C to be installed at a higher level\. D is still installed
  454. at the top level because nothing conflicts with it\.
  455. .P
  456. For \fBA{B,C}, B{C,D@1}, C{D@2}\fP, this algorithm produces:
  457. .P
  458. .RS 2
  459. .nf
  460. A
  461. +\-\- B
  462. +\-\- C
  463. `\-\- D@2
  464. +\-\- D@1
  465. .fi
  466. .RE
  467. .P
  468. Because B's D@1 will be installed in the top level, C now has to install D@2
  469. privately for itself\. This algorithm is deterministic, but different trees may
  470. be produced if two dependencies are requested for installation in a different
  471. order\.
  472. .P
  473. See npm help 5 folders for a more detailed description of the specific
  474. folder structures that npm creates\.
  475. .SS Limitations of npm's Install Algorithm
  476. .P
  477. npm will refuse to install any package with an identical name to the
  478. current package\. This can be overridden with the \fB\-\-force\fP flag, but in
  479. most cases can simply be addressed by changing the local package name\.
  480. .P
  481. There are some very rare and pathological edge\-cases where a cycle can
  482. cause npm to try to install a never\-ending tree of packages\. Here is
  483. the simplest case:
  484. .P
  485. .RS 2
  486. .nf
  487. A \-> B \-> A' \-> B' \-> A \-> B \-> A' \-> B' \-> A \-> \.\.\.
  488. .fi
  489. .RE
  490. .P
  491. where \fBA\fP is some version of a package, and \fBA'\fP is a different version
  492. of the same package\. Because \fBB\fP depends on a different version of \fBA\fP
  493. than the one that is already in the tree, it must install a separate
  494. copy\. The same is true of \fBA'\fP, which must install \fBB'\fP\|\. Because \fBB'\fP
  495. depends on the original version of \fBA\fP, which has been overridden, the
  496. cycle falls into infinite regress\.
  497. .P
  498. To avoid this situation, npm flat\-out refuses to install any
  499. \fBname@version\fP that is already present anywhere in the tree of package
  500. folder ancestors\. A more correct, but more complex, solution would be
  501. to symlink the existing version into the new location\. If this ever
  502. affects a real use\-case, it will be investigated\.
  503. .SH SEE ALSO
  504. .RS 0
  505. .IP \(bu 2
  506. npm help 5 folders
  507. .IP \(bu 2
  508. npm help update
  509. .IP \(bu 2
  510. npm help audit
  511. .IP \(bu 2
  512. npm help link
  513. .IP \(bu 2
  514. npm help rebuild
  515. .IP \(bu 2
  516. npm help 7 scripts
  517. .IP \(bu 2
  518. npm help build
  519. .IP \(bu 2
  520. npm help config
  521. .IP \(bu 2
  522. npm help 7 config
  523. .IP \(bu 2
  524. npm help 5 npmrc
  525. .IP \(bu 2
  526. npm help 7 registry
  527. .IP \(bu 2
  528. npm help dist\-tag
  529. .IP \(bu 2
  530. npm help uninstall
  531. .IP \(bu 2
  532. npm help shrinkwrap
  533. .IP \(bu 2
  534. npm help 5 package\.json
  535. .RE