In the Angular Component Router documentation I just stumbled over a npm command I have never seen before and I don't understand what is going on:
npm install @angular/router --save
What is the meaning of @angular/router
?
Is the whole string a package name? But then I dont find that package when I use the search on npmjs.com. And also the commandline search does return no such package:
npm search @angular/router :No match found for "@angular/router"
So is the @angular/
some kind of prefix mechanism in npm? And how does it work?
Major, minor and patch represent the different releases of a package. npm uses the tilde (~) and caret (^) to designate which patch and minor versions to use respectively. So if you see ~1.0. 2 it means to install version 1.0. 2 or the latest patch version such as 1.0.
This is the closest parent directory to contain a package. json file or node_modules directory, unless -g is also specified. If -g is specified, this will be the value of the global prefix. See npm config for more detail.
The default on OS X is /usr/local , which means that npm will symlink binaries into /usr/local/bin , which should already be on your PATH (especially if you're using Homebrew).
The next tag is used by some projects to identify the upcoming version.By default, other than latest, no tag has any special significance to npm itself.
This is a new feature of NPM called 'scoped packages', which effectively allow NPM packages to be namespaced. Every user and organization on NPM has their own scope, and they are the only people who can add packages to it.
This is useful for several reasons:
@angular
, you know it was published by the Angular core team.http
is already taken in the main repository, but Angular is able to have @angular/http
as well.The reason that scoped packages don't show up in public search is because a lot of them are private packages created by organizations using NPM's paid services, and they're not comfortable opening the search up until they can be totally certain they're not going to make anything public that shouldn't be public - from a legal perspective, this is pretty understandable.
For more information, see the NPM docs and the Angular docs.
EDIT: It appears that public scoped packages now show up properly in search!
Basically there are two types of modules on npm, they are -
Global modules - these are modules that follow the naming convention that exists today. You require('foo')
and there is much rejoicing. They are owned by one or more people through the npm install XYZ
command.
Scoped modules - these are new modules that are "scoped" under an organization name that begins with an @
the organisation's name, a slash and finally the package name, e.g. @someOrgScope/packagename
. Scopes are a way of grouping related packages together, and also affect a few things about the way npm treats the package.
A scoped package is installed by referencing it by name, preceded by an @-symbol, in npm install:
npm install @myorg/mypackage
see also
http://blog.nodejitsu.com/a-summary-of-scoped-modules-in-npm/
https://docs.npmjs.com/misc/scope
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With