]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/doc/misc/npm-scope.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / doc / misc / npm-scope.md
1 npm-scope(7) -- Scoped packages
2 ===============================
3
4 ## DESCRIPTION
5
6 All npm packages have a name. Some package names also have a scope. A scope
7 follows the usual rules for package names (url-safe characters, no leading dots
8 or underscores). When used in package names, preceded by an @-symbol and
9 followed by a slash, e.g.
10
11     @somescope/somepackagename
12
13 Scopes are a way of grouping related packages together, and also affect a few
14 things about the way npm treats the package.
15
16 Scoped packages can be published and installed as of `npm@2` and are supported
17 by the primary npm registry. The npm client is backwards-compatible with
18 un-scoped registries, so it can be used to work with scoped and un-scoped
19 registries at the same time.
20
21 ## Installing scoped packages
22
23 Scoped packages are installed to a sub-folder of the regular installation
24 folder, e.g. if your other packages are installed in `node_modules/packagename`,
25 scoped modules will be in `node_modules/@myorg/packagename`. The scope folder
26 (`@myorg`) is simply the name of the scope preceded by an @-symbol, and can
27 contain any number of scoped packages.
28
29 A scoped package is installed by referencing it by name, preceded by an
30 @-symbol, in `npm install`:
31
32     npm install @myorg/mypackage
33
34 Or in `package.json`:
35
36     "dependencies": {
37       "@myorg/mypackage": "^1.3.0"
38     }
39
40 Note that if the @-symbol is omitted in either case npm will instead attempt to
41 install from GitHub; see `npm-install(1)`.
42
43 ## Requiring scoped packages
44
45 Because scoped packages are installed into a scope folder, you have to
46 include the name of the scope when requiring them in your code, e.g.
47
48     require('@myorg/mypackage')
49
50 There is nothing special about the way Node treats scope folders, this is
51 just specifying to require the module `mypackage` in the folder called `@myorg`.
52
53 ## Publishing scoped packages
54
55 Scoped packages can be published from the CLI as of `npm@2` and can be
56 published to any registry that supports them, including the primary npm
57 registry.
58
59 (As of 2015-04-19, and with npm 2.0 or newer, the primary npm registry **does**
60 support scoped packages)
61
62 If you wish, you may associate a scope with a registry; see below.
63
64 ### Publishing public scoped packages to the primary npm registry
65
66 To publish a public scoped package, you must specify `--access public` with
67 the initial publication.  This will publish the package and set access
68 to `public` as if you had run `npm access public` after publishing.
69
70 ### Publishing private scoped packages to the npm registry
71
72 To publish a private scoped package to the npm registry, you must have
73 an [npm Private Modules](https://www.npmjs.com/private-modules)
74 account.
75
76 You can then publish the module with `npm publish` or `npm publish
77 --access restricted`, and it will be present in the npm registry, with
78 restricted access.  You can then change the access permissions, if
79 desired, with `npm access` or on the npmjs.com website.
80
81 ## Associating a scope with a registry
82
83 Scopes can be associated with a separate registry. This allows you to
84 seamlessly use a mix of packages from the primary npm registry and one or more
85 private registries, such as npm Enterprise.
86
87 You can associate a scope with a registry at login, e.g.
88
89     npm login --registry=http://reg.example.com --scope=@myco
90
91 Scopes have a many-to-one relationship with registries: one registry can
92 host multiple scopes, but a scope only ever points to one registry.
93
94 You can also associate a scope with a registry using `npm config`:
95
96     npm config set @myco:registry http://reg.example.com
97
98 Once a scope is associated with a registry, any `npm install` for a package
99 with that scope will request packages from that registry instead. Any
100 `npm publish` for a package name that contains the scope will be published to
101 that registry instead.
102
103 ## SEE ALSO
104
105 * npm-install(1)
106 * npm-publish(1)
107 * npm-access(1)