繁体   English   中英

npm 错误! 403 403 禁止 npm 发布

[英]npm ERR! 403 403 Forbidden npm publish

我尝试在 npm 上发布公共包,但出现此错误

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@clem_b%2fweather - Forbidden
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

所以首先看我下面的package.json

{
  "name": "@clem_b/weather",
  "version": "1.0.6",
  "description": "weather cli",
  "main": "build/main.js",
  "types": "build/main.d.ts",
  "homepage": "https://github.com/ClementBolin/weatherCLI#readme",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ClementBolin/weatherCLI.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "rimraf ./build && tsc",
    "start": "npm run build && node build/mai.js"
  },
  "bin": {
    "app": "bin/weatherCLI"
  },
  "keywords": [
    "weather",
    "today",
    "rain",
    "sun"
  ],
  "author": "clem_b",
  "license": "MIT",
  "devDependencies": {
    "@types/minimist": "^1.2.0",
    "@types/node": "^14.14.6",
    "@types/oauth": "^0.9.1",
    "@types/ora": "^3.2.0",
    "rimraf": "^3.0.2",
    "tslint": "^6.1.3",
    "typescript": "^4.0.5"
  },
  "prepublish": "npm run build",
  "dependencies": {
    "minimist": "^1.2.5",
    "oauth": "^0.9.15",
    "ora": "^0.3.0"
  }
}

所以在写完我的代码之后,我决定在 npm 上发布我的代码,所以我创建了 npm 帐户,我使用npm login连接到我的帐户。 在此之后,我运行以下命令npm publish --access public并且我在顶部写入错误。 我搜索了很多主题,但我没有找到解决方案

我自己也遇到了这个。 我创建了一个新的 NPM 帐户,然后立即通过npm login进行身份验证。

然后,我运行npm publish --access public并收到完全相同的错误消息。

我能够通过验证我的 NPM (doh) 电子邮件帐户来解决问题。

在 npm 配置文件的 ACCOUNT 部分中,您必须激活 2FA,然后在 2FA 选项中选择“启用授权和发布”。

如果已经这样做,请验证您的项目是否与已注册的另一个项目具有相同的名称。 在这种情况下,如果有,只需更改名称。

只需验证您的电子邮件。 再次尝试发布包

检查名称是否在 npm 中保留,在我的情况下,该名称已被使用,也尝试

sudo npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz

npm 上可能已经存在同名的包。 更改 package.json 中的包名,然后重试。

就我而言,在我创建了一个团队(在我的 NPM 组织内)并将自己添加为该团队的成员后,问题得到了解决。

见: https ://github.com/npm/cli/issues/1012#issuecomment-629546298

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM