私有 npm 发布注意 - alo7

公司使用 npm 管理工具有一些使用的细节,记录
更新于: 2025-07-19 07:39:07

安装与发布

  • 安装与发布是不同的 registry 地址
# 安装
npm i --registry=https://repos.saybot.net/repository/alo7npm/

# 登录与发布
npm login --registry=https://repos.saybot.net/repository/alo7-private-npm/
npm publish

使用注意

  • 个人的 npm 可能无法发包成功
  • 公用的 npm 账户,可能被别人重置 token,所以,会用到上面的 npm login 重新登录
  • 有时候需要删除 ~/.npmrc 里的 _authToken 配置,login 才会更新 token
  • npm 小版本变化的时候,会有缓存,需要 invalid 缓存才会正常安装新的包,此为已知的 BUG
    • 因为此 registry 找包路径为 alo7npm → taobao-npm → 就停了 ,这就是BUG产生的原因
    • 理论上会找到 npm.com 才对,所以另一种解决方案是,发完包去 cnpm sync YOUR_PACKAGE

清理缓存的命令

此命令里有个人信息,所以,地址设置为 Private

发布有问题

0 verbose cli /Users/ap7/.nvm/versions/node/v20.19.2/bin/node /Users/ap7/.nvm/versions/node/v20.19.2/bin/npm
1 info using npm@10.8.2
2 info using node@v20.19.2
3 silly config load:file:/Users/ap7/.nvm/versions/node/v20.19.2/lib/node_modules/npm/npmrc
4 info config found workspace root at /Users/ap7/saybot/dsr-packages
5 silly config load:file:/Users/ap7/saybot/dsr-packages/.npmrc
6 silly config load:file:/Users/ap7/.npmrc
7 silly config load:file:/Users/ap7/.nvm/versions/node/v20.19.2/etc/npmrc
8 verbose title npm publish .
9 verbose argv "publish" "." "--tag" "latest"
10 verbose logfile logs-max:10 dir:/Users/ap7/.npm/_logs/2025-07-17T01_26_25_040Z-
11 verbose logfile /Users/ap7/.npm/_logs/2025-07-17T01_26_25_040Z-debug-0.log
12 silly logfile start cleaning logs, removing 1 files
13 silly logfile done cleaning log files
14 verbose publish [ '/Users/ap7/saybot/dsr-packages/packages/dsr-normalize' ]
15 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
16 notice
17 notice 📦  @alo7/dsr-normalize@1.0.16
18 notice Tarball Contents
19 notice 54B README.md
19 notice 19.8kB dist/index.cjs.js
19 notice 34.4kB dist/index.cjs.js.map
19 notice 146B dist/index.d.ts
19 notice 19.8kB dist/index.esm.js
19 notice 34.4kB dist/index.esm.js.map
19 notice 22.3kB dist/index.umd.js
19 notice 34.4kB dist/index.umd.js.map
19 notice 8.1kB dist/index.umd.min.js
19 notice 25.5kB dist/index.umd.min.js.map
19 notice 1.4kB package.json
19 notice 296B src/index.ts
19 notice 676B src/request/index.ts
19 notice 320B src/request/pipes/chivox/core-type-en.pict.score.ts
19 notice 322B src/request/pipes/chivox/core-type-retell.score.ts
19 notice 325B src/request/pipes/common/core-type-en.pred.score.ts
19 notice 339B src/request/pipes/common/core-type-retell.score.ts
19 notice 754B src/request/utils/process-prtl.ts
19 notice 339B src/response/index.ts
19 notice 2.2kB src/response/pipes/audio-url.ts
19 notice 1.0kB src/response/pipes/core-type-retell.score.ts
19 notice 831B src/response/pipes/snt-details.ts
19 notice 203B src/types.ts
20 notice Tarball Details
21 notice name: @alo7/dsr-normalize
22 notice version: 1.0.16
23 notice filename: alo7-dsr-normalize-1.0.16.tgz
24 notice package size: 40.8 kB
25 notice unpacked size: 208.0 kB
26 notice shasum: e5de2c780bd5a3aff8d688fafabe8abb7f43069a
27 notice integrity: sha512-sEeUJ6uv7WG9W[...]2iSja4FglFe5A==
28 notice total files: 23
29 notice
30 verbose stack Error: This command requires you to be logged in to https://repos.saybot.net/repository/alo7npm
30 verbose stack     at #publish (/Users/ap7/.nvm/versions/node/v20.19.2/lib/node_modules/npm/lib/commands/publish.js:144:29)
30 verbose stack     at async Publish.execWorkspaces (/Users/ap7/.nvm/versions/node/v20.19.2/lib/node_modules/npm/lib/commands/publish.js:54:9)
30 verbose stack     at async Npm.exec (/Users/ap7/.nvm/versions/node/v20.19.2/lib/node_modules/npm/lib/npm.js:207:9)
30 verbose stack     at async module.exports (/Users/ap7/.nvm/versions/node/v20.19.2/lib/node_modules/npm/lib/cli/entry.js:74:5)
31 error code ENEEDAUTH
32 error need auth This command requires you to be logged in to https://repos.saybot.net/repository/alo7npm
33 error need auth You need to authorize this machine using `npm adduser`
34 verbose cwd /Users/ap7/saybot/dsr-packages/packages/dsr-normalize
35 verbose os Darwin 23.6.0
36 verbose node v20.19.2
37 verbose npm  v10.8.2
38 verbose exit 1
39 verbose code 1
40 error A complete log of this run can be found in: /Users/ap7/.npm/_logs/2025-07-17T01_26_25_040Z-debug-0.log

结论

  • npm login 的时候,会用这个 --registry=https://repos.saybot.net/repository/alo7npm/
  • 但实际生成的 token,要将 alo7npm → alo7-private-npm 特别注意
strict-ssl=false
registry=https://registry.npmmirror.com
@jswork:registry=https://registry.npmjs.org
@afeiship:registry=https://npm.pkg.github.com
@alo7:registry=https://repos.saybot.net/repository/alo7npm
home=https://mirrors.cloud.tencent.com/npm/
//npm.pkg.github.com/:_authToken=ABV
//registry.npmjs.org/:_authToken=BCD
//repos.saybot.net/repository/alo7-private-npm/:_authToken=AVCD
git-tag-version=false
init-author-name=afeiship
scripts-prepend-node-path=true
proxy=false
user=0
python=/Users/ap7/.pyenv/shims/python2

参考

参考链接为,内网地址,外网无法访问