everkm-publish 0.16.9 → 0.16.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everkm-publish",
3
- "version": "0.16.9",
3
+ "version": "0.16.11",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "postinstall": "node install.js",
@@ -0,0 +1,53 @@
1
+ ## npm 发布 `everkm-publish@0.16.9` 问题记录
2
+
3
+ ### 背景
4
+ - 在本地项目 `everkm-publish-npm` 中执行 `npm publish`。
5
+ - `package.json` 中的包名为 `everkm-publish`,版本为 `0.16.9`。
6
+
7
+ ### 现象
8
+ - npm 日志里出现:
9
+ - `PUT https://registry.npmjs.org/everkm-publish 404 Not Found`
10
+ - `error code E404`
11
+ - 随后检查身份时执行:
12
+ - `npm config get registry` 输出 `https://registry.npmjs.org/`
13
+ - `npm whoami` 返回:
14
+ - `npm error code E401`
15
+ - `npm error 401 Unauthorized - GET https://registry.npmjs.org/-/whoami`
16
+
17
+ ### 原因分析
18
+ - `registry` 已指向官方 `https://registry.npmjs.org/`,说明不是源配置错误。
19
+ - `npm whoami` 返回 `E401 Unauthorized`,表明当前 npm **未登录或登录状态失效**。
20
+ - 在未授权的情况下执行 `publish`,导致与 registry 交互时出现异常,表现为:
21
+ - `npm publish` 请求 `PUT https://registry.npmjs.org/everkm-publish` 时返回 `404 Not Found`。
22
+ - 结合 `E401` 来看,实质问题是**认证失败**而不是资源真的不存在。
23
+
24
+ ### 解决方案
25
+ 1. 确认 registry:
26
+ ```bash
27
+ npm config get registry
28
+ # 期望输出:
29
+ # https://registry.npmjs.org/
30
+ ```
31
+ 2. 重新登录 npm:
32
+ ```bash
33
+ npm login
34
+ # 按提示输入用户名、密码、邮箱以及(如有)2FA 验证
35
+ ```
36
+ 3. 确认登录成功:
37
+ ```bash
38
+ npm whoami
39
+ # 能正常输出 npm 用户名即表示登录成功
40
+ ```
41
+ 4. 再次发布:
42
+ ```bash
43
+ npm publish --registry=https://registry.npmjs.org/
44
+ ```
45
+
46
+ ### 经验与教训
47
+ - 遇到 npm `E404` 且伴随 `E401 Unauthorized` 时,需要优先检查 **登录状态**,而不仅仅是 registry 配置。
48
+ - 在发布前可以先执行一次:
49
+ ```bash
50
+ npm whoami
51
+ ```
52
+ 确认身份有效,再进行 `npm publish`,可以避免掉在认证问题上浪费时间。
53
+