maitxn/version-bump-tar
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: Package spec |
| 3 | section: 7 |
| 4 | description: Package name specifier |
| 5 | github_repo: npm/cli |
| 6 | github_branch: latest |
| 7 | github_path: docs/lib/content/using-npm/package-spec.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/misc/package-spec |
| 10 | - /cli-documentation/using-npm/package-spec |
| 11 | - /cli-documentation/v11/misc/package-spec |
| 12 | - /cli-documentation/v11/using-npm/package-spec |
| 13 | - /cli/misc/package-spec |
| 14 | - /cli/using-npm/package-spec |
| 15 | - /cli/v11/misc/package-spec |
| 16 | - /misc/package-spec |
| 17 | - /using-npm/package-spec |
| 18 | --- |
| 19 | |
| 20 | ### Description |
| 21 | |
| 22 | Commands like `npm install` and the dependency sections in the `package.json` 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 `<package-spec>` in the help output for the npm commands that use this package name specifier. |
| 23 | |
| 24 | ### Package name |
| 25 | |
| 26 | - `[<@scope>/]<pkg>` |
| 27 | - `[<@scope>/]<pkg>@<tag>` |
| 28 | - `[<@scope>/]<pkg>@<version>` |
| 29 | - `[<@scope>/]<pkg>@<version range>` |
| 30 | |
| 31 | 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 [registry](/cli/v11/using-npm/config#registry) config to refer to a package in a registry. |
| 32 | |
| 33 | Examples: |
| 34 | |
| 35 | - `npm` |
| 36 | - `@npmcli/arborist` |
| 37 | - `@npmcli/arborist@latest` |
| 38 | - `npm@6.13.1` |
| 39 | - `npm@^4.0.0` |
| 40 | |
| 41 | ### Aliases |
| 42 | |
| 43 | - `<alias>@npm:<name>` |
| 44 | |
| 45 | Primarily used by commands like `npm install` and in the dependency sections in the `package.json`, this refers to a package by an alias. The `<alias>` is the name of the package as it is reified in the `node_modules` folder, and the `<name>` refers to a package name as found in the configured registry. |
| 46 | |
| 47 | See `Package name` above for more info on referring to a package by name, and [registry](/cli/v11/using-npm/config#registry) for configuring which registry is used when referring to a package by name. |
| 48 | |
| 49 | Examples: |
| 50 | |
| 51 | - `semver@npm:@npmcli/semver-with-patch` |
| 52 | - `semver@npm:semver@7.2.2` |
| 53 | - `semver@npm:semver@legacy` |
| 54 | |
| 55 | ### Folders |
| 56 | |
| 57 | - `<folder>` |
| 58 | |
| 59 | This refers to a package on the local filesystem. Specifically this is a folder with a `package.json` file in it. This _should_ always be prefixed with a `/` or `./` (or your OS equivalent) to reduce confusion. npm currently will parse a string with more than one `/` in it as a folder, but this is legacy behavior that may be removed in a future version. |
| 60 | |
| 61 | Examples: |
| 62 | |
| 63 | - `./my-package` |
| 64 | - `/opt/npm/my-package` |
| 65 | |
| 66 | ### Tarballs |
| 67 | |
| 68 | - `<tarball file>` |
| 69 | - `<tarball url>` |
| 70 | |
| 71 | Examples: |
| 72 | |
| 73 | - `./my-package.tgz` |
| 74 | - `https://registry.npmjs.org/semver/-/semver-1.0.0.tgz` |
| 75 | |
| 76 | 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. |
| 77 | |
| 78 | ### git urls |
| 79 | |
| 80 | - `<git:// url>` |
| 81 | - `<github username>/<github project>` |
| 82 | |
| 83 | 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 `#ref`. |
| 84 | |
| 85 | Examples: |
| 86 | |
| 87 | - `https://github.com/npm/cli.git` |
| 88 | - `git@github.com:npm/cli.git` |
| 89 | - `git+ssh://git@github.com/npm/cli#v6.0.0` |
| 90 | - `github:npm/cli#HEAD` |
| 91 | - `npm/cli#c12ea07` |
| 92 | |
| 93 | ### See also |
| 94 | |
| 95 | - [npm-package-arg](https://npm.im/npm-package-arg) |
| 96 | - [scope](/cli/v11/using-npm/scope) |
| 97 | - [config](/cli/v11/using-npm/config) |