summaryrefslogtreecommitdiff
path: root/deps/npm/man/man7/npm-scope.7
blob: f876e4eaaa65fd26b336e275bc7644afc0595536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
.TH "NPM\-SCOPE" "7" "October 2014" "" ""
.SH "NAME"
\fBnpm-scope\fR \- Scoped packages
.SH DESCRIPTION
.P
All npm packages have a name\. Some package names also have a scope\. A scope
follows the usual rules for package names (url\-safe characters, no leading dots
or underscores)\. When used in package names, preceded by an @\-symbol and
followed by a slash, e\.g\.
.P
.RS 2
.nf
@somescope/somepackagename
.fi
.RE
.P
Scopes are a way of grouping related packages together, and also affect a few
things about the way npm treats the package\.
.P
\fBAs of 2014\-09\-03, scoped packages are not supported by the public npm registry\fR\|\.
However, the npm client is backwards\-compatible with un\-scoped registries, so
it can be used to work with scoped and un\-scoped registries at the same time\.
.SH Installing scoped packages
.P
Scoped packages are installed to a sub\-folder of the regular installation
folder, e\.g\. if your other packages are installed in \fBnode_modules/packagename\fR,
scoped modules will be in \fBnode_modules/@myorg/packagename\fR\|\. The scope folder
(\fB@myorg\fR) is simply the name of the scope preceded by an @\-symbol, and can
contain any number of scoped packages\.
.P
A scoped package is installed by referencing it by name, preceded by an
@\-symbol, in \fBnpm install\fR:
.P
.RS 2
.nf
npm install @myorg/mypackage
.fi
.RE
.P
Or in \fBpackage\.json\fR:
.P
.RS 2
.nf
"dependencies": {
  "@myorg/mypackage": "^1\.3\.0"
}
.fi
.RE
.P
Note that if the @\-symbol is omitted in either case npm will instead attempt to
install from GitHub; see npm help \fBnpm\-install\fR\|\.
.SH Requiring scoped packages
.P
Because scoped packages are installed into a scope folder, you have to
include the name of the scope when requiring them in your code, e\.g\.
.P
.RS 2
.nf
require('@myorg/mypackage')
.fi
.RE
.P
There is nothing special about the way Node treats scope folders, this is
just specifying to require the module \fBmypackage\fR in the folder called \fB@myorg\fR\|\.
.SH Publishing scoped packages
.P
Scoped packages can be published to any registry that supports them\.
\fIAs of 2014\-09\-03, the public npm registry does not support scoped packages\fR,
so attempting to publish a scoped package to the registry will fail unless
you have associated that scope with a different registry, see below\.
.SH Associating a scope with a registry
.P
Scopes can be associated with a separate registry\. This allows you to
seamlessly use a mix of packages from the public npm registry and one or more
private registries, such as npm Enterprise\.
.P
You can associate a scope with a registry at login, e\.g\.
.P
.RS 2
.nf
npm login \-\-registry=http://reg\.example\.com \-\-scope=@myco
.fi
.RE
.P
Scopes have a many\-to\-one relationship with registries: one registry can
host multiple scopes, but a scope only ever points to one registry\.
.P
You can also associate a scope with a registry using \fBnpm config\fR:
.P
.RS 2
.nf
npm config set @myco:registry http://reg\.example\.com
.fi
.RE
.P
Once a scope is associated with a registry, any \fBnpm install\fR for a package
with that scope will request packages from that registry instead\. Any
\fBnpm publish\fR for a package name that contains the scope will be published to
that registry instead\.
.SH SEE ALSO
.RS 0
.IP \(bu 2
npm help install
.IP \(bu 2
npm help publish

.RE