GM
V2EX  ›  Node.js

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

  •  
  •   GM · Sep 23, 2021 · 10673 views
    This topic created in 1866 days ago, the information mentioned may be changed or developed.
    17 replies  •  2021-10-25 10:16:05 +08:00
    AoEiuV020
    AoEiuV020
    Sep 23, 2021❤️1
    1
    带 @多一级不会和别人重复,比如我有个包叫 hello, 但全局的 hello 已经有人占了,我就可以发在自己名下叫做 @AoEiuV020/hello
    randyo
    randyo
    Sep 23, 2021
    2
    最近配置 .npmrc,设置了 registry 为淘宝源,又设置另一个私有包到私有源,发现不带 @ 它就走淘宝源,给私有包加了 @ 再配置,就可以了。这个私有包走私有源,其他包走淘宝源。
    L1shen
    L1shen
    Sep 23, 2021❤️2
    4
    @ 代表是 npm 上的一个组织,也有命名空间的作用
    ayase252
    ayase252
    Sep 23, 2021
    5
    避免 npm 包命名冲突。
    比如 facebook 上传了个叫 react 的包,其他所有开发者都不能够使用 react 这个名字了。
    cydysm
    cydysm
    Sep 23, 2021
    6
    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
    Sep 23, 2021 via Android
    7
    好像是谷歌先这么干的
    dropsio
    dropsio
    Sep 23, 2021
    8
    一切源于模仿...
    Biwood
    Biwood
    Sep 23, 2021❤️5
    9
    什么叫喜欢用 @ ,这不是 npm 中的 scope 定义方式吗,通过这帖子发现不少“知其然不知其所以然”的人
    mightofcode
    mightofcode
    Sep 23, 2021
    10
    yep
    KouShuiYu
    KouShuiYu
    Sep 23, 2021
    11
    因为这是 npm 推荐的方式 https://docs.npmjs.com/cli/v7/using-npm/scope
    GM
    GM
    OP
    Sep 24, 2021
    12
    @Biwood 这位兄台,莫非你对所有东西都“知其然且知其所以然”?你从来不碰到疑问?碰到不了解的事情你都不问问题??
    OliveGlaze
    OliveGlaze
    Sep 24, 2021
    13
    前端工程化,@表示 scope

    至于为啥用 @表示就不清楚了。我只能说 convention 千千万,能找到个常用符号表示就说明这个 convention 是还算是值得一学一用的。
    magicdawn
    magicdawn
    Sep 24, 2021
    14
    前端还喜欢 包 @版本

    npm i lodash@latest

    就是取 @的 At 意思吧, 然后 @username / orgname 表示用户的, 互联网上大家用惯了, weibo twitter
    alanhe421
    alanhe421
    Oct 5, 2021
    15
    scope......
    zxCoder
    zxCoder
    Oct 16, 2021
    16
    还喜欢用 @next
    dany813
    dany813
    Oct 25, 2021
    17
    @yunyuyuan 这个解释的不错
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1266 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 21:10 · PVG 05:10 · LAX 13:10 · JFK 16:10
    ♥ Do have faith in what you're doing.