5

为什么前端界这么喜欢用 @ 号做为包名前缀?有什么好处或者目的吗?

 2 years ago
source link: https://www.v2ex.com/t/803685
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Node.js

为什么前端界这么喜欢用 @ 号做为包名前缀?有什么好处或者目的吗?

  GM · 14 小时 43 分钟前 · 1799 次点击
11 条回复    2021-09-23 18:39:47 +08:00

AoEiuV020

AoEiuV020   14 小时 39 分钟前   ❤️ 1

带 @多一级不会和别人重复,比如我有个包叫 hello, 但全局的 hello 已经有人占了,我就可以发在自己名下叫做 @AoEiuV020/hello

randyo

randyo   14 小时 38 分钟前

最近配置 .npmrc,设置了 registry 为淘宝源,又设置另一个私有包到私有源,发现不带 @ 它就走淘宝源,给私有包加了 @ 再配置,就可以了。这个私有包走私有源,其他包走淘宝源。

L1shen

L1shen   14 小时 37 分钟前   ❤️ 1

@ 代表是 npm 上的一个组织,也有命名空间的作用

ayase252

ayase252   14 小时 36 分钟前

避免 npm 包命名冲突。
比如 facebook 上传了个叫 react 的包,其他所有开发者都不能够使用 react 这个名字了。

cydysm

cydysm   14 小时 31 分钟前

https://docs.npmjs.com/cli/v7/using-npm/scope
这个叫 scope
Scopes are a way of grouping related packages together, and also affect a few things about the way npm treats the package.

Each npm user/organization has their own scope, and only you can add packages in your scope. This means you don't have to worry about someone taking your package name ahead of you. Thus it is also a good way to signal official packages for organizations.

suzic

suzic   13 小时 50 分钟前 via Android

好像是谷歌先这么干的

dropsio

dropsio   13 小时 6 分钟前

一切源于模仿...

Biwood

Biwood   12 小时 53 分钟前   ❤️ 1

什么叫喜欢用 @ ,这不是 npm 中的 scope 定义方式吗,通过这帖子发现不少“知其然不知其所以然”的人

mightofcode

mightofcode   12 小时 42 分钟前


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK