如何解决运行“ npm publish”时出现404错误
我正在尝试将软件包发布到npm注册表。但是当我按下命令npm publish
时,我得到了这个错误。
npm WARN prepublish-on-install As of npm@5,`prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.
> imojha@1.0.0 prepublish .
> npm run build
> imojha@1.0.0 build /home/suraj/Projects/bitandbang
> node build.js
npm notice
npm notice ? imojha@1.0.0
npm notice === Tarball Contents ===
npm notice 1.1kB LICENSE
npm notice 3.6kB bin/output
npm notice 233B bin/card.js
npm notice 996B package.json
npm notice 293B README.md
npm notice === Tarball Details ===
npm notice name: imojha
npm notice version: 1.0.0
npm notice package size: 2.3 kB
npm notice unpacked size: 6.2 kB
npm notice shasum: bb283ae5fe8aed311771f369866c13e24f1eb937
npm notice integrity: sha512-Nzc+Ysmf4RgSi[...]XoT+OGYHNHoSQ==
npm notice total files: 5
npm notice
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.registry.github.com/imojha
npm ERR! 404
npm ERR! 404 'imojha@1.0.0' 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! A complete log of this run can be found in:
npm ERR! /home/suraj/.npm/_logs/2020-10-24T14_54_01_996Z-debug.log
我已经成功运行npm login
。然后我正在执行npm publish
。
我已经从GitHub克隆了此仓库,并发布到了npm。这实际上是关于创建自己名字的npx卡,例如npx用户名。我也一样。
我试图给它一个不同的包名,但是没有成功。所以,有人可以告诉我我在做什么错吗?这是package.json文件。
{
"name": "suraj-ojha","version": "1.0.0","description": "A personal card for Suraj Ojha (@suraj)","main": "/bin/card.js","bin": {
"bitandbang": "./bin/card.js"
},"repository": {
"type": "git","url": "git@github.com:Suraez/npxcard.git"
},"homepage": "https://bnb.im","scripts": {
"prepublish": "npm run build","build": "node build.js","dev": "npm run build && node ./bin/card.js","lint": "standard","test": "echo \"Error: no test specified\" && exit 1"
},"keywords": [
"card","npm","npm card","npx","npx card","business card"
],"author": "suraj Ojha","license": "MIT","files": [
"bin/card.js","bin/output"
],"devDependencies": {
"boxen": "^2.1.0","chalk": "^2.4.1","standard": "^12.0.1"
},"bugs": {
"url": "https://github.com/bnb/bitandbang/issues"
},"dependencies": {},"publishConfig": {
"registry": "https://npm.registry.github.com/"
}
}
解决方法
publishConfig
URL可能是错误的。
您可以尝试在publishConfig
中添加package.json
选项吗?
"publishConfig": {
"registry":"https://npm.pkg.github.com"
},
,
更新:我相信它是由于您主文件夹中.npmrc
的问题引起的。混乱$ HOME变量似乎也使它失败。删除该文件,然后重新登录npm似乎可以解决此问题。
除了答案之外,Suraj Oberai您的问题用所有必要的信息措辞都很好,我认为您不应该接受否决票。
我已经发布了许多npm软件包,但这是我第一次亲自遇到此问题。非常奇怪,因为这与我发布的以前的软件包几乎没有区别。我不得不通过使用我的一个工作包来追踪该问题,并且(后来许多无用的发布)慢慢地将其转换为我的尝试,该尝试导致了该错误,直到项目之间几乎没有什么区别。除了外壳程序的HOME Env变量。
这绝对是npm的错误。看来上面的错误是默认错误,所以可能我的更改可能无法为您解决此问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。