“at”是什么意思? npm包上的(@)前缀? [英] What is the meaning of the "at" (@) prefix on npm packages?

查看:298
本文介绍了“at”是什么意思? npm包上的(@)前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular Component Router文档中,我偶然发现了一个我以前从未见过的npm命令我不明白发生了什么:

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

@ angular / router 是什么意思?

整个字符串是包名吗?但是当我在 npmjs.com 上使用搜索时,我找不到该包。
并且命令行搜索确实没有返回此类包:

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"

所以 @angular / npm中的某种前缀机制?它是如何工作的?

So is the @angular/ some kind of prefix mechanism in npm? And how does it work?

推荐答案

这是NPM的新功能,称为范围包,它有效地允许NPM包被命名空间。 NPM上的每个用户和组织都有自己的范围,他们是唯一可以添加软件包的人。

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 can add packages to it.

这有几个原因:


  • 它允许组织明确哪些包是正式的,哪些包不是。


    • 例如,如果包的范围 @angular ,您知道它是由Angular核心团队。

    • It allows organizations to make it clear which packages are 'official' and which ones are not.
      • For example, if a package has the scope @angular, you know it was published by the Angular core team.

      • 例如,包名称 http 已经在主存储库中获取,但Angular能够还有 @ angular / http

      • For example, the package name http is already taken in the main repository, but Angular is able to have @angular/http as well.

      范围包未出现在公共搜索中的原因因为很多都是使用NPM付费服务的组织创建的私人包裹,他们不习惯开放搜索,直到他们完全确定他们不会公开任何不公开的内容 - 从法律角度来看,这是可以理解的。

      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.

      有关更多信息,请参阅 NPM docs Angular docs

      For more information, see the NPM docs and the Angular docs.

      编辑:看来公共范围的软件包现在可以在搜索中正确显​​示!

      这篇关于“at”是什么意思? npm包上的(@)前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆