npm ERR! 403403 Forbidden npm发布

时间:2020-11-06 16:29:00

标签: node.js npm

我尝试在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,并且在顶部出现错误。 我搜索了许多主题,但找不到解决方法

2 个答案:

答案 0 :(得分:6)

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

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

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

答案 1 :(得分:-1)

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

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