在 org 内部:如何发布 npm 包

🕐

公司内部,如何发布 npm private 包

01 生成自己的 github_token

到这里: https://github.com/settings/tokens,添加 tokens(classic). 

  • 生成一个只读的,明文写到 .npmrc
  • 生成一个可写的(用于发布包)

02 添加一个普通的只读 token

.npmrc 示例

@bosinc:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=ghp_this_is_a_pubic_readonly_token

03 本地添加 .npmrc

.npmrc 示例

@bosinc:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=ghp_rw_token

04 npmConfig 配置

添加 npmConfig 到 package.json

{
  "name": "@bosinc/shared",
  "version": "0.1.1",
  "description": "A react library developed with dumi",
  "publishConfig": {
    "registry": "https://npm.pkg.github.com"
  },
  "authors": [
    "wgbx"
  ]
}
npm
private
内部