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