| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 | .TH "SCOPE" "7" "August 2021" "" "".SH "NAME"\fBscope\fR \- Scoped packages.SS Description.PAll npm packages have a name\. Some package names also have a scope\. A scopefollows the usual rules for package names (URL\-safe characters, no leading dotsor underscores)\. When used in package names, scopes are preceded by an \fB@\fP symboland followed by a slash, e\.g\..P.RS 2.nf@somescope/somepackagename.fi.RE.PScopes are a way of grouping related packages together, and also affect a fewthings about the way npm treats the package\..PEach npm user/organization has their own scope, and only you can add packagesin your scope\. This means you don't have to worry about someone taking yourpackage name ahead of you\. Thus it is also a good way to signal official packagesfor organizations\..PScoped packages can be published and installed as of \fBnpm@2\fP and are supportedby the primary npm registry\. Unscoped packages can depend on scoped packages andvice versa\. The npm client is backwards\-compatible with unscoped registries,so it can be used to work with scoped and unscoped registries at the same time\..SS Installing scoped packages.PScoped packages are installed to a sub\-folder of the regular installationfolder, e\.g\. if your other packages are installed in \fBnode_modules/packagename\fP,scoped modules will be installed in \fBnode_modules/@myorg/packagename\fP\|\. The scopefolder (\fB@myorg\fP) is simply the name of the scope preceded by an \fB@\fP symbol, and cancontain any number of scoped packages\..PA scoped package is installed by referencing it by name, preceded by an\fB@\fP symbol, in \fBnpm install\fP:.P.RS 2.nfnpm install @myorg/mypackage.fi.RE.POr in \fBpackage\.json\fP:.P.RS 2.nf"dependencies": {  "@myorg/mypackage": "^1\.3\.0"}.fi.RE.PNote that if the \fB@\fP symbol is omitted, in either case, npm will instead attempt toinstall from GitHub; see npm help \fBinstall\fP\|\..SS Requiring scoped packages.PBecause scoped packages are installed into a scope folder, you have toinclude the name of the scope when requiring them in your code, e\.g\..P.RS 2.nfrequire('@myorg/mypackage').fi.RE.PThere is nothing special about the way Node treats scope folders\. Thissimply requires the \fBmypackage\fP module in the folder named \fB@myorg\fP\|\..SS Publishing scoped packages.PScoped packages can be published from the CLI as of \fBnpm@2\fP and can bepublished to any registry that supports them, including the primary npmregistry\..P(As of 2015\-04\-19, and with npm 2\.0 or better, the primary npm registry\fBdoes\fR support scoped packages\.).PIf you wish, you may associate a scope with a registry; see below\..SS Publishing public scoped packages to the primary npm registry.PTo publish a public scoped package, you must specify \fB\-\-access public\fP withthe initial publication\. This will publish the package and set accessto \fBpublic\fP as if you had run \fBnpm access public\fP after publishing\..SS Publishing private scoped packages to the npm registry.PTo publish a private scoped package to the npm registry, you must havean npm Private Modules \fIhttps://docs\.npmjs\.com/private\-modules/intro\fRaccount\..PYou can then publish the module with \fBnpm publish\fP or \fBnpm publish\-\-access restricted\fP, and it will be present in the npm registry, withrestricted access\. You can then change the access permissions, ifdesired, with \fBnpm access\fP or on the npmjs\.com website\..SS Associating a scope with a registry.PScopes can be associated with a separate registry\. This allows you toseamlessly use a mix of packages from the primary npm registry and one or moreprivate registries, such as npm Enterprise\..PYou can associate a scope with a registry at login, e\.g\..P.RS 2.nfnpm login \-\-registry=http://reg\.example\.com \-\-scope=@myco.fi.RE.PScopes have a many\-to\-one relationship with registries: one registry canhost multiple scopes, but a scope only ever points to one registry\..PYou can also associate a scope with a registry using \fBnpm config\fP:.P.RS 2.nfnpm config set @myco:registry http://reg\.example\.com.fi.RE.POnce a scope is associated with a registry, any \fBnpm install\fP for a packagewith that scope will request packages from that registry instead\. Any\fBnpm publish\fP for a package name that contains the scope will be published tothat registry instead\..SS See also.RS 0.IP \(bu 2npm help install.IP \(bu 2npm help publish.IP \(bu 2npm help access.IP \(bu 2npm help registry.RE
 |