Team Ai
Datasetpublic

codekingpro/portable-devtools

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