javascript - 运行 "npm publish"时出现 404 错误

标签 javascript node.js npm npm-publish

我正在尝试将包发布到 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 克隆了这个 repo 并发布到 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网址可能有误。
您可以尝试添加 publishConfig package.json 中的选项:

"publishConfig": {
    "registry":"https://npm.pkg.github.com"
},

关于javascript - 运行 "npm publish"时出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64514891/

相关文章:

javascript - 是否可以使用nodejs/npm启动具有不同权限的js文件?

node.js - 无法升级 - slimerjs 丢失...?

Angular 5 和 NPM

javascript - 使用模板但保留 jquery 绑定(bind)?

javascript - 缩小时的 Angular 注入(inject)

node.js - 从私有(private) git 存储库安装/更新包时,npm 真的很慢

javascript - 用户与加密数据的关系 Sequelize 数据库

npm - 我需要从 ".gitignore"复制粘贴内容到 ".npmignore"

javascript - canvg 无法在 Edge 中工作

javascript - 如何在javascript中清除间隔?