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

查看:40
本文介绍了“在"是什么意思?(@) 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 who 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 文档Angular 文档.

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

      看来 公共范围的包现在可以正确显示在搜索中!

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

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