You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法发布包至NPM:执行npm publish时遇404错误求助

解决GitHub npm注册表发布404错误的问题

你遇到的404错误核心原因是GitHub npm注册表要求包必须是作用域包,且配置不完整,以下是具体修复步骤:

1. 修正package.json的关键配置

  • 强制添加作用域前缀:将name字段改为@hypetf/pcm-converter(hypetf是你的GitHub用户名),GitHub Packages不支持无作用域的包名。
  • 添加publishConfig字段:在package.json中加入:
    "publishConfig": {
      "registry": "https://npm.pkg.github.com/"
    }
    

2. 确认仓库权限与配置

  • 检查GitHub仓库pcm-converter的设置:确保仓库已开启GitHub Packages功能(仓库Settings -> Packages -> 确认允许发布)。
  • 确认你的GitHub账号拥有该仓库的写入权限(是仓库所有者或有推送权限的协作者)。

3. 验证npm配置与登录状态

  • 执行npm config get registry,确认输出为https://npm.pkg.github.com/,若不是则执行:
    npm config set registry https://npm.pkg.github.com/
    
  • 重新登录时,确保使用的Personal Access Token(PAT)拥有write:packages和repo权限:
    1. 前往GitHub设置 -> Developer settings -> Personal access tokens生成新token,勾选上述权限。
    2. 执行npm login --registry=https://npm.pkg.github.com/,用户名填GitHub账号,密码填生成的token,邮箱填GitHub绑定邮箱。

4. 重新发布

完成上述配置后,执行:

npm publish

或直接指定注册表发布:

npm publish --registry=https://npm.pkg.github.com/

附你遇到的错误日志片段:

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/pcm-converter
npm ERR! 404 'pcm-converter@1.0.0' is not in this registry.

内容的提问来源于stack exchange,提问作者hypetf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 16:20:21