尝试将新包发布到NPM时获取404

时间:2016-08-24 05:30:10

标签: node.js npm npm-publish

我刚刚创建了一个新包: https://github.com/supericium/pli

我现在正试图像这样第一次将它发布到NPM:

    ole@MKI:~/Sandbox/pli$ npm publish  --access public
    npm ERR! publish Failed PUT 404
    npm ERR! Linux 3.13.0-93-generic
    npm ERR! argv "/home/ole/.nvm/versions/v6.4.0/bin/node" "/home/ole/.nvm/versions/v6.4.0/bin/npm" "publish" "--access" "public"
    npm ERR! node v6.4.0
    npm ERR! npm  v3.10.3
    npm ERR! code E404

    npm ERR! 404 Not found : @supericium/pli
    npm ERR! 404 
    npm ERR! 404  '@supericium/pli' is not in the npm registry.
    npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
    npm ERR! 404 
    npm ERR! 404 Note that you can also install from a
    npm ERR! 404 tarball, folder, http url, or git url.

    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/ole/Sandbox/pli/npm-debug.log

我尝试更新NodeJS和NPM,以确保我有最新版本,其中包括:

ole@MKI:~/Sandbox/pli$ node --version
v6.4.0
ole@MKI:~/Sandbox/pli$ npm --version
3.10.3

思想?

TIA, 奥莱

14 个答案:

答案 0 :(得分:12)

在我的情况下,此问题已由npm login解决,错误消息令人误解

答案 1 :(得分:6)

将密码更改为NPM但未通过CLI注销/登录时,也会出现此错误。使用npm logout然后使用npm login对我有用。

答案 2 :(得分:5)

您需要在注册表中注册“supericium”(npm adduser)作为用户名并登录以在该范围内发布。

答案 3 :(得分:3)

遇到这个相同的错误,我的问题是该软件包以某种方式设置为仅“读取”访问权限。因此,我必须转到NPM并将软件包更新为“读/写”访问权限:

1。

enter image description here

2。

enter image description here

答案 4 :(得分:1)

就我而言,我注意到我在npm网站中的 npm帐户用户名不同于我的 npm普通用户名。当我尝试使用普通用户名通过登录在控制台中发布时,出现此错误。

  

发布失败的PUT 404 npm错误!代码E404 npm ERR! 404找不到用户

但是使用帐户名登录控制台后,它已成功发布

答案 5 :(得分:1)

成功发布该程序包后,您尝试npm install时可能会遇到:

npm ERR! code E404
npm ERR! 404 Not Found: @xxx/yyy@latest

或类似内容,无论您npm publish是否成功。在这种情况下,请确保您在package.json中的{main: 'file.js'}在那。

理想情况下,如果您希望直接从软件包中窃取内容,可以将其命名为index.js,这样您就不会得到import * from '@xxx/yyy/file'这样的东西。

答案 6 :(得分:1)

就我而言,我必须验证电子邮件地址。即使npm whoami告诉我我已经登录正常。

答案 7 :(得分:1)

就我而言,我收到此消息是因为我使用的令牌已被撤销。我通过以下方式修复它:

  1. 在我的 npm 帐户中生成一个新的访问令牌。
  2. 在我的 .zshrc(或 .bashrc)文件中修改行:export NPM_TOKEN="<token>"
  3. 在终端中输入 source ~/.zshrc

答案 8 :(得分:0)

我遇到了同样的问题,但是我通过卸载LTS版本,然后与纱线一起安装了当前版本成功地解决了该问题。

答案 9 :(得分:0)

就我而言,我不小心输入了https://registry.npmjs.org而不是https://registry.npmjs.com(。org与.com)

答案 10 :(得分:0)

就我而言,我在尝试发布的新软件包的repository中缺少package.json字段。

"repository": "git://github.com/your-org/your-repo-name.git"

https://docs.npmjs.com/files/package.json#repository

答案 11 :(得分:0)

只需将我的两分钱添加到可能的解决方案中

我在 CI 工作流中遇到此错误,因此没有交互式登录或相关内容。 现有的包可以正常工作,但添加一个新包却不能正常工作,我收到了 404。我意识到这应该与新包本身有关,而不是与 CI 环境有关,而且确实如此。

新包的 package.json 中缺少两个字段,即 repositorypublishConfig 字段。

添加这两个字段,它工作正常(注意 repository 字段以其扩展形式使用,带有 directory 属性)

"repository": {
  "type": "git",
  "url": "ssh://git@github.com/__user__/__repo-name__.git",
  "directory": "packages/__new-package-name__"
},
"publishConfig": {
  "registry": "https://npm.pkg.github.com/"
}

答案 12 :(得分:0)

我刚刚使用 npm adduser 命令登录到 npm 并且运行良好。

答案 13 :(得分:-3)

如果您是从ubuntu环境发布的,请先通过 npm login 然后就做

sudo npm publish