Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

javascript - npm软件包上的“ at”(@)前缀是什么意思? [重复](What is the meaning of the “at” (@) prefix on npm packages? [duplicate])

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:(在Angular Component Router文档中,我偶然碰到了一个从未见过的npm命令,我不知道发生了什么:)

npm install @angular/router --save What is the meaning of @angular/router ?(@angular/router是什么意思?) Is the whole string a package name?(整个字符串是包名吗?) But then I dont find that package when I use the search on npmjs.com .(但是当我在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?(那么@angular/是npm中的某种前缀机制吗?) And how does it work?(以及它如何运作?)   ask by jbandi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a new feature of NPM called 'scoped packages', which effectively allow NPM packages to be namespaced.(这是NPM的一项新功能,称为“作用域软件包”,可有效地使NPM软件包具有名称空间。)

Every user and organization on NPM has their own scope, and they are the only people can add packages to it.(NPM上的每个用户和组织都有自己的范围,并且是唯一可以向其中添加软件包的人员。) This is useful for several reasons:(这很有用,原因如下:) 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.(例如,如果包的作用域为@angular ,则您知道它是由Angular核心团队发布的。) The package name only has to be unique to the scope it is published in, not the entire registry.(程序包名称仅对于发布的范围是唯一的,而不是整个注册表。) For example, the package name http is already taken in the main repository, but Angular is able to have @angular/http as well.(例如,包名称http已在主存储库中使用,但是Angular也可以具有@angular/http 。) 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付费服务的组织创建的私有软件包,并且他们不满意打开搜索,直到可以完全确定它们不是将会公开任何不应该公开的东西-从法律的角度来看,这是可以理解的。) For more information, see the NPM docs and the Angular docs .(有关更多信息,请参阅NPM文档Angular文档 。) EDIT: It appears that public scoped packages now show up properly in search!(编辑:似乎公共范围的软件包现在可以正确显示在搜索中!)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...