In the Angular 组件路由器文档 https://docs.angularjs.org/guide/component-router我刚刚偶然发现了一个我以前从未见过的 npm 命令,我不明白发生了什么:
npm install @angular/router --save
是什么意思@angular/router
?
整个字符串是包名吗?但是当我使用搜索时我没有找到该包npmjs.com https://www.npmjs.com/。
而且命令行搜索也没有返回这样的包:
npm search @angular/router
:No match found for "@angular/router"
也是如此@angular/
npm 中的某种前缀机制?它是如何运作的?
这是 NPM 的一项新功能,称为“作用域包”,它有效地允许 NPM 包具有命名空间。 NPM 上的每个用户和组织都有自己的范围,并且他们是唯一可以向其添加包的人。
这很有用,原因如下:
- It allows organizations to make it clear which packages are 'official' and which ones are not.
- 例如,如果一个包的范围是
@angular
,你知道它是由 Angular 核心团队发布的。
- The package name only has to be unique to the scope it is published in, not the entire registry.
- 例如,包名
http
已在主存储库中获取,但 Angular 能够拥有@angular/http
以及。
原因是范围内的包不会出现在公共搜索中 https://github.com/npm/npm/issues/8244是因为其中很多都是由使用 NPM 付费服务的组织创建的私人软件包,他们不愿意打开搜索,直到他们完全确定他们不会公开任何不应该公开的内容 - 从从法律的角度来看,这是很好理解的。
欲了解更多信息,请参阅NPM docs https://docs.npmjs.com/getting-started/scoped-packages和角度文档 https://angular.io/docs/ts/latest/guide/glossary.html#scoped-package.
EDIT:看起来公共范围的包现在可以正确显示在搜索中! https://www.npmjs.com/search?q=%40angular
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)