"PACKAGE-SPEC" "7" "February 2024" "" ""
"NAME"
package-spec - Package name specifier
"Description"

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.

"Package name"

\(bu 4
\[lB]<@scope>/\[rB]<pkg>
\(bu 4
\[lB]<@scope>/\[rB]<pkg>@<tag>
\(bu 4
\[lB]<@scope>/\[rB]<pkg>@<version>
\(bu 4
\[lB]<@scope>/\[rB]<pkg>@<version range>

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 \(la/using-npm/config#registry\(ra config to refer to a package in a registry.

Examples:

\(bu 4
npm
\(bu 4
@npmcli/arborist
\(bu 4
@npmcli/arborist@latest
\(bu 4
npm@6.13.1
\(bu 4
npm@^4.0.0
"Aliases"

\(bu 4
<alias>@npm:<name>

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.

See Package name above for more info on referring to a package by name, and registry \(la/using-npm/config#registry\(ra for configuring which registry is used when referring to a package by name.

Examples:

\(bu 4
semver:@npm:@npmcli/semver-with-patch
\(bu 4
semver:@npm:semver@7.2.2
\(bu 4
semver:@npm:semver@legacy
"Folders"

\(bu 4
<folder>

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.

Examples:

\(bu 4
./my-package
\(bu 4
/opt/npm/my-package
"Tarballs"

\(bu 4
<tarball file>
\(bu 4
<tarball url>

Examples:

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.

"git urls"

\(bu 4
<git:// url>
\(bu 4
<github username>/<github project>

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.

Examples:

\(bu 4
https://github.com/npm/cli.git
\(bu 4
git@github.com:npm/cli.git
\(bu 4
git+ssh://git@github.com/npm/cli#v6.0.0
\(bu 4
github:npm/cli#HEAD
\(bu 4
npm/cli#c12ea07
"See also"

\(bu 4
npm-package-arg \(lahttps://npm.im/npm-package-arg\(ra
\(bu 4
npm help scope
\(bu 4
npm help config