11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: package-spec
31cb0ef41Sopenharmony_cisection: 7
41cb0ef41Sopenharmony_cidescription: Package name specifier
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Description
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciCommands like `npm install` and the dependency sections in the
101cb0ef41Sopenharmony_ci`package.json` use a package name specifier.  This can be many different
111cb0ef41Sopenharmony_cithings that all refer to a "package".  Examples include a package name,
121cb0ef41Sopenharmony_cigit url, tarball, or local directory.  These will generally be referred
131cb0ef41Sopenharmony_cito as `<package-spec>` in the help output for the npm commands that use
141cb0ef41Sopenharmony_cithis package name specifier.
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci### Package name
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci* `[<@scope>/]<pkg>`
191cb0ef41Sopenharmony_ci* `[<@scope>/]<pkg>@<tag>`
201cb0ef41Sopenharmony_ci* `[<@scope>/]<pkg>@<version>`
211cb0ef41Sopenharmony_ci* `[<@scope>/]<pkg>@<version range>`
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciRefers to a package by name, with or without a scope, and optionally
241cb0ef41Sopenharmony_citag, version, or version range.  This is typically used in combination
251cb0ef41Sopenharmony_ciwith the [registry](/using-npm/config#registry) config to refer to a
261cb0ef41Sopenharmony_cipackage in a registry.
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciExamples:
291cb0ef41Sopenharmony_ci* `npm`
301cb0ef41Sopenharmony_ci* `@npmcli/arborist`
311cb0ef41Sopenharmony_ci* `@npmcli/arborist@latest`
321cb0ef41Sopenharmony_ci* `npm@6.13.1`
331cb0ef41Sopenharmony_ci* `npm@^4.0.0`
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci### Aliases
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci* `<alias>@npm:<name>`
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciPrimarily used by commands like `npm install` and in the dependency
401cb0ef41Sopenharmony_cisections in the `package.json`, this refers to a package by an alias.
411cb0ef41Sopenharmony_ciThe `<alias>` is the name of the package as it is reified in the
421cb0ef41Sopenharmony_ci`node_modules` folder, and the `<name>` refers to a package name as
431cb0ef41Sopenharmony_cifound in the configured registry.
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ciSee `Package name` above for more info on referring to a package by
461cb0ef41Sopenharmony_ciname, and [registry](/using-npm/config#registry) for configuring which
471cb0ef41Sopenharmony_ciregistry is used when referring to a package by name.
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciExamples:
501cb0ef41Sopenharmony_ci* `semver:@npm:@npmcli/semver-with-patch`
511cb0ef41Sopenharmony_ci* `semver:@npm:semver@7.2.2`
521cb0ef41Sopenharmony_ci* `semver:@npm:semver@legacy`
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci### Folders
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci* `<folder>`
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ciThis refers to a package on the local filesystem.  Specifically this is
591cb0ef41Sopenharmony_cia folder with a `package.json` file in it.  This *should* always be
601cb0ef41Sopenharmony_ciprefixed with a `/` or `./` (or your OS equivalent) to reduce confusion.
611cb0ef41Sopenharmony_cinpm currently will parse a string with more than one `/` in it as a
621cb0ef41Sopenharmony_cifolder, but this is legacy behavior that may be removed in a future
631cb0ef41Sopenharmony_civersion.
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ciExamples:
661cb0ef41Sopenharmony_ci
671cb0ef41Sopenharmony_ci* `./my-package`
681cb0ef41Sopenharmony_ci* `/opt/npm/my-package`
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci### Tarballs
711cb0ef41Sopenharmony_ci
721cb0ef41Sopenharmony_ci* `<tarball file>`
731cb0ef41Sopenharmony_ci* `<tarball url>`
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ciExamples:
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci* `./my-package.tgz`
781cb0ef41Sopenharmony_ci* `https://registry.npmjs.org/semver/-/semver-1.0.0.tgz`
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ciRefers to a package in a tarball format, either on the local filesystem
811cb0ef41Sopenharmony_cior remotely via url.  This is the format that packages exist in when
821cb0ef41Sopenharmony_ciuploaded to a registry.
831cb0ef41Sopenharmony_ci
841cb0ef41Sopenharmony_ci### git urls
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci* `<git:// url>`
871cb0ef41Sopenharmony_ci* `<github username>/<github project>`
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ciRefers to a package in a git repo.  This can be a full git url, git
901cb0ef41Sopenharmony_cishorthand, or a username/package on GitHub.  You can specify a
911cb0ef41Sopenharmony_cigit tag, branch, or other git ref by appending `#ref`.
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ciExamples:
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ci* `https://github.com/npm/cli.git`
961cb0ef41Sopenharmony_ci* `git@github.com:npm/cli.git`
971cb0ef41Sopenharmony_ci* `git+ssh://git@github.com/npm/cli#v6.0.0`
981cb0ef41Sopenharmony_ci* `github:npm/cli#HEAD`
991cb0ef41Sopenharmony_ci* `npm/cli#c12ea07`
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci### See also
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ci* [npm-package-arg](https://npm.im/npm-package-arg)
1041cb0ef41Sopenharmony_ci* [scope](/using-npm/scope)
1051cb0ef41Sopenharmony_ci* [config](/using-npm/config)
106