npm ERR! 403 403 Forbidden npm publish
Asked Answered
R

10

15

I try to publish public package on npm but I have this error

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.

So in first watch my package.jsonbelow.

{
  "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"
  }
}

So after end to write my code, I decide to publish my code on npm, so I create npm account, I use npm loginfor connect to my account. After this I run the following command npm publish --access publicand I have error write in top. I search on many topics, but I don't find solution

Ret answered 6/11, 2020 at 16:29 Comment(0)
P
24

just ran into this myself. I created a new NPM account and then immediately authenticated via npm login.

Then, I ran npm publish --access public and received the exact same error message.

I was able to resolve the issue by verifying my email account for NPM (doh).

Paulus answered 24/12, 2020 at 18:12 Comment(2)
Email verification was the case for me too.Phan
Same here ... a little hint in the docs would be greatRobbie
S
4

Probably there is already a package with the same name present on npm. Change package name in package.json and try again.

Stateless answered 4/4, 2022 at 7:31 Comment(0)
L
1

In my case, the problem was resolved after I created a team (within my NPM organization) and added myself as a member to that team.

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

Lath answered 24/4, 2021 at 0:54 Comment(0)
V
0

In npm profile, in ACCOUNT section, you must activate 2FA and after select "Enabled for authorization and publishing" inside of 2FA options.

If already do this, verify if your project has the same name of another project registered. In this case if has, just change the name.

Volume answered 8/2, 2022 at 11:56 Comment(0)
G
0

check if the name is reserved in npm in my case the name was alrady used also try

sudo npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz
Groat answered 18/3, 2022 at 13:17 Comment(0)
T
0

So my scenario was i was using jenkins to publish the npm was using npm publish it was giving error that i cannot push after 1.0.0 so after checking i found that the in package.json file in version it was mentioned "1.0.0" so i needed to change the build number as per my jenkins build i used sed to do that

Trapezohedron answered 22/9, 2022 at 4:22 Comment(0)
P
0

I updated the name part in package.json and it works now.

Paquette answered 12/2, 2023 at 4:46 Comment(0)
M
0

This can also be happens when you are using LAN(private network) network and if in that network IP is applied for restricting.

In my case this was the case.

Matherne answered 17/3, 2023 at 8:35 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Autosuggestion
C
0

1. Authentication Issues: ** -- Check npm login status: Run npm whoami to verify you're logged in with the correct account that has publishing permissions. **Log in if needed: ** If not logged in, run npm login and enter your npm credentials.

2. Existing Package Name:

  • Check for existing package: Use npm view pack-ui to see if the package name is already taken.
  • Choose a different name: If it exists, rename your package in package.json to a unique name.

3. Organization Permissions:

  • Verify permissions: If publishing under an organization scope (e.g., @your-org/pack-ui), ensure you have publishing permissions within that organization.

4.npm Cache -- Clear cache: Try clearing the npm cache with npm cache clean --force.

Coaxial answered 1/3 at 22:30 Comment(0)
D
0

This sequence of actions worked for me

  • login to npm before creating the package npm login --auth-type=legacy

Note : --auth-type=legacy is to prevent the login happen in the browser

  • create the package

    npm init

Note: - select a package name that does NOT exist - add yourself as author

  • Publish the package

    npm publish

Dongola answered 17/7 at 19:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.