package-spec.7 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. .TH "SPEC" "7" "March 2026" "NPM@11.12.0" ""
  2. .SH "NAME"
  3. \fBspec\fR - Package name specifier
  4. .SS "Description"
  5. .P
  6. Commands like \fBnpm install\fR and the dependency sections in the \fBpackage.json\fR use a package name specifier. This can be many different things that all refer to a "package". Examples include a package name, git url, tarball, or local directory. These will generally be referred to as \fB<package-spec>\fR in the help output for the npm commands that use this package name specifier.
  7. .SS "Package name"
  8. .RS 0
  9. .IP \(bu 4
  10. \fB\[lB]<@scope>/\[rB]<pkg>\fR
  11. .IP \(bu 4
  12. \fB\[lB]<@scope>/\[rB]<pkg>@<tag>\fR
  13. .IP \(bu 4
  14. \fB\[lB]<@scope>/\[rB]<pkg>@<version>\fR
  15. .IP \(bu 4
  16. \fB\[lB]<@scope>/\[rB]<pkg>@<version range>\fR
  17. .RE 0
  18. .P
  19. Refers to a package by name, with or without a scope, and optionally tag, version, or version range. This is typically used in combination with the \fBregistry\fR \fI\(la/using-npm/config#registry\(ra\fR config to refer to a package in a registry.
  20. .P
  21. Examples:
  22. .RS 0
  23. .IP \(bu 4
  24. \fBnpm\fR
  25. .IP \(bu 4
  26. \fB@npmcli/arborist\fR
  27. .IP \(bu 4
  28. \fB@npmcli/arborist@latest\fR
  29. .IP \(bu 4
  30. \fBnpm@6.13.1\fR
  31. .IP \(bu 4
  32. \fBnpm@^4.0.0\fR
  33. .RE 0
  34. .SS "Aliases"
  35. .RS 0
  36. .IP \(bu 4
  37. \fB<alias>@npm:<name>\fR
  38. .RE 0
  39. .P
  40. Primarily used by commands like \fBnpm install\fR and in the dependency sections in the \fBpackage.json\fR, this refers to a package by an alias. The \fB<alias>\fR is the name of the package as it is reified in the \fBnode_modules\fR folder, and the \fB<name>\fR refers to a package name as found in the configured registry.
  41. .P
  42. See \fBPackage name\fR above for more info on referring to a package by name, and \fBregistry\fR \fI\(la/using-npm/config#registry\(ra\fR for configuring which registry is used when referring to a package by name.
  43. .P
  44. Examples:
  45. .RS 0
  46. .IP \(bu 4
  47. \fBsemver@npm:@npmcli/semver-with-patch\fR
  48. .IP \(bu 4
  49. \fBsemver@npm:semver@7.2.2\fR
  50. .IP \(bu 4
  51. \fBsemver@npm:semver@legacy\fR
  52. .RE 0
  53. .SS "Folders"
  54. .RS 0
  55. .IP \(bu 4
  56. \fB<folder>\fR
  57. .RE 0
  58. .P
  59. This refers to a package on the local filesystem. Specifically this is a folder with a \fBpackage.json\fR file in it. This \fIshould\fR always be prefixed with a \fB/\fR or \fB./\fR (or your OS equivalent) to reduce confusion. npm currently will parse a string with more than one \fB/\fR in it as a folder, but this is legacy behavior that may be removed in a future version.
  60. .P
  61. Examples:
  62. .RS 0
  63. .IP \(bu 4
  64. \fB./my-package\fR
  65. .IP \(bu 4
  66. \fB/opt/npm/my-package\fR
  67. .RE 0
  68. .SS "Tarballs"
  69. .RS 0
  70. .IP \(bu 4
  71. \fB<tarball file>\fR
  72. .IP \(bu 4
  73. \fB<tarball url>\fR
  74. .RE 0
  75. .P
  76. Examples:
  77. .RS 0
  78. .IP \(bu 4
  79. \fB./my-package.tgz\fR
  80. .IP \(bu 4
  81. \fBhttps://registry.npmjs.org/semver/-/semver-1.0.0.tgz\fR
  82. .RE 0
  83. .P
  84. Refers to a package in a tarball format, either on the local filesystem or remotely via url. This is the format that packages exist in when uploaded to a registry.
  85. .SS "git urls"
  86. .RS 0
  87. .IP \(bu 4
  88. \fB<git:// url>\fR
  89. .IP \(bu 4
  90. \fB<github username>/<github project>\fR
  91. .RE 0
  92. .P
  93. Refers to a package in a git repo. This can be a full git url, git shorthand, or a username/package on GitHub. You can specify a git tag, branch, or other git ref by appending \fB#ref\fR.
  94. .P
  95. Examples:
  96. .RS 0
  97. .IP \(bu 4
  98. \fBhttps://github.com/npm/cli.git\fR
  99. .IP \(bu 4
  100. \fBgit@github.com:npm/cli.git\fR
  101. .IP \(bu 4
  102. \fBgit+ssh://git@github.com/npm/cli#v6.0.0\fR
  103. .IP \(bu 4
  104. \fBgithub:npm/cli#HEAD\fR
  105. .IP \(bu 4
  106. \fBnpm/cli#c12ea07\fR
  107. .RE 0
  108. .SS "See also"
  109. .RS 0
  110. .IP \(bu 4
  111. \fBnpm-package-arg\fR \fI\(lahttps://npm.im/npm-package-arg\(ra\fR
  112. .IP \(bu 4
  113. npm help scope
  114. .IP \(bu 4
  115. npm help config
  116. .RE 0