cli icon indicating copy to clipboard operation
cli copied to clipboard

npm publish 404 Not Found - PUT

Open 1000i100 opened this issue 6 years ago • 42 comments

The nearest issue is #1626 but it's about using npm to get package, and it look solved for most user. Here it's about npm publishing package in CI, and it's not solved for now.

Current Behavior:

https://framagit.org/1000i100/g1lien/-/jobs/1072053

$ npm publish
[...]
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/g1link - Not found
npm ERR! 404 
npm ERR! 404  '[email protected]' 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.
[...]

Expected Behavior:

Successful publish of my package from docker in gitlab-CI with npm_token authentication. (it works yesterday on my laptop with npm login, but not with npm_token in CI).

Steps To Reproduce:

ex. steps to reproduce the behavior:

  1. Fork this : https://framagit.org/1000i100/g1lien
  2. change the package name and add your npm token
  3. push it with a tag on a gitlab with CI active.

It should reproduce the problem.

Environment:

https://framagit.org/1000i100/g1lien/-/blob/master/.gitlab-ci.yml#L5 https://framagit.org/1000i100/g1lien/-/jobs/1072052#L17

  • OS: Docker in gitlab with image: node:current
  • Node: v14.7.0
  • NPM: 6.14.7

1000i100 avatar Aug 07 '20 10:08 1000i100

Same error.

Last release 30.07 was successful. But since 11.08 I get this error when publish: 2020-08-13T09:56:54.1669946Z 18 http fetch PUT 404 https://registry.npmjs.org/@aurigma%2fui-framework 5611ms 2020-08-13T09:56:54.1670114Z 19 verbose stack Error: 404 Not Found - PUT https://registry.npmjs.org/@aurigma%2fui-framework - Not found

maxsmaleha avatar Aug 14 '20 06:08 maxsmaleha

I was trying to npm publish from a new machine and got the same unexpected 404. In my case it was solved by an npm login. I understand that a 401 could "leak" the presence of a private package, but I would think the CLI would first check to see whether I was authenticated first and respond with a more appropriate error.

Here is the relevant portion of the log when I tried to npm publish before npm login:

19 verbose stack Error: 404 Not Found - PUT https://registry.npmjs.org/mock-fs - Not found
19 verbose stack     at /Users/tschaub/.nvm/versions/node/v14.8.0/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:117:15
19 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
20 verbose statusCode 404
21 verbose pkgid [email protected]
22 verbose cwd /Users/tschaub/projects/mock-fs
23 verbose Darwin 19.6.0
24 verbose argv "/Users/tschaub/.nvm/versions/node/v14.8.0/bin/node" "/Users/tschaub/.nvm/versions/node/v14.8.0/bin/npm" "publish"
25 verbose node v14.8.0
26 verbose npm  v6.14.8
27 error code E404
28 error 404 Not Found - PUT https://registry.npmjs.org/mock-fs - Not found
29 error 404
30 error 404 '[email protected]' is not in the npm registry.
31 error 404 You should bug the author to publish it (or use the name yourself!)
32 error 404 Note that you can also install from a
33 error 404 tarball, folder, http url, or git url.
34 verbose exit [ 1, true ]

tschaub avatar Aug 20 '20 23:08 tschaub

Yeah, npm login helps. A few days ago I discovered this too. But still it is not clear why I had to re-authorize Npm should improve their error messages.

maxsmaleha avatar Aug 21 '20 04:08 maxsmaleha

Hitting this issue too. Honestly I've had so many bugs / problems with npm and registries. It's a comedy of errors.

Right now I just did a login, removed all tokens, created a new one. Updated my .npmrc then did an npm ping

which works properly.

Then an npm publish gives me "not found".

I have to remove the .npmrc then do an npm login and then it works.

The problem is that this completely breaks our release process and we can't use a CI system for our releases.

NPM... you need to take these issues seriously. They really negatively impact your brand. Bugs like this and SO many in one area shouldn't exist. Either remove the features or fix them.

InputNeuron avatar Nov 29 '20 17:11 InputNeuron

Have you tried with npm 7?

ljharb avatar Nov 29 '20 17:11 ljharb

@ljharb I haven't ... could try that. was being lazy on upgrading 👍

InputNeuron avatar Nov 30 '20 16:11 InputNeuron

Also getting this error in my CI, I'm using token for login and trying to publish package which was previously published, still got 404: CI run Sometimes I get 503, but that's probably just because I try to publish too many of them at a time... CI run 503 Related issue: https://github.com/Maxim-Mazurok/google-api-typings-generator/issues/418

Using npm v6.14.10

Maxim-Mazurok avatar Jan 25 '21 06:01 Maxim-Mazurok

i fixed my problem by adding tags pattern v* as protected in gitlab. My CI silently failed to acces the token because it was only available on protected branch and tags and i had no protected tags and no publish task on protected branch.

1000i100 avatar Jan 28 '21 08:01 1000i100

I'm experiencing the same problem recently. First I thought I messed up my CI, but when I manually login to github packages using my personal access token I get the same error.

My process:

$ npm login --registry=https://npm.pkg.github.com/
  > Username: 1nvitr0
  > Password: my token with write:package access
  > Email: (this IS public) my email
  > Logged in as 1nvitr0 on https://npm.pkg.github.com/.

When i run npm publish I receive a 404 error:

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/package-name The expected resource was not found.
npm ERR! 404 
npm ERR! 404  'package-name@version' 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.

UPDATE

Nevermind, I had an outdated repository URL and package name in my package.json. Updating that fixed the Error. But getting a 404 most definitely did not make that clear in any way.

1nVitr0 avatar Mar 14 '21 14:03 1nVitr0

Hi

DId someone proceed with this error in CI? I came across the same error in GitHubActions. This is how workflow looks like

name: Node.js Package

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 15
      - run: npm ci
      - run: npm test

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 15
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          token: ${{ secrets.NPM_TOKEN }}

sleshJdev avatar Mar 15 '21 08:03 sleshJdev

Hi

DId someone proceed with this error in CI? I came across the same error in GitHubActions. This is how workflow looks like

On Monday, this was working. Today I am not getting 404 errors on publish from a GH Action.

UPDATE:

Explicitly adding the config value of registry-url: https://registry.npmjs.org/ resolved this issue for use. This was not needed before, but with it we are seeing the publish action work again.

clok avatar Mar 18 '21 18:03 clok

Hi, here

I found a resource from npm and this works for me.

Here's the drone.yml sample from my project.


Steps:

  1. generate automation type npm token
  2. create .npmrc and write //registry.npmjs.org/:_authToken=${NPM_TOKEN} into it

wiasliaw avatar Mar 22 '21 03:03 wiasliaw

I received a 404 until I provided a repository field in package.json when publishing to Github Packaages. Unhelpful error.

bdefore avatar Jul 21 '21 22:07 bdefore

npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@prisma%2ftemplates - Not found

Is the 2%f encoding just a terminal rendering artifact or is that actually what is being attempted to be published and thus the 404?

npm login is not helping my case.

jasonkuhrt avatar Oct 20 '21 01:10 jasonkuhrt

npm logout - login doesn't help..sometimes help npmrc auth file doesn't help..sometimes help.. Whatever written here people tried hundreds of times without any result, and the issue is "Closed". The issue is not closed! it's a persisting issue that have even blog posts about it!

why publishing package should be this hard? why do you have to centralize and authorize things this far in open-source software development?!! I have 7 packages and 20 years of experience and every single time I spend an hour figuring out how to publish the next package!

Generally what works to make npm 100% sure that you are the right person is generating a new "automation" auth token and changing your home directory .npmrc and project directory .npmrc to this below (you may exclude github).

@OWNER:registry=https://npm.pkg.github.com
registry-url: https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=npm_Ruz84svT6MS5asOryxQOihlxxxxxxxxxx

ghost avatar Dec 30 '21 09:12 ghost

Updated fixed my issue, typeo dotnethailand => dotnetthailand, missing one t.

Leave original comment here if people found the same issue.

I have tried million ways but I could not fix this issue. Here is the error messages that I got after executing npm publish --access public to publish the first version of my package.

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@dotnethailand%2fgatsby-theme-minimal-portfolio - Scope not found
npm ERR! 404 
npm ERR! 404  '@dotnethailand/[email protected]' 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.

I can confirm that I have an organization dotnethailand which I am the owner.

Additional information:

  • NPM username: aaronamm
  • Organization name: dotnetthailand
  • Package name: @dotnetthailand/gatsby-theme-minimal-portfolio
  • NPM version: 6.14.15
  • Node.JS version: v12.22.7
  • OS version: Ubuntu 18.04.5 LTS - link to my package.json
  • Accessed https://registry.npmjs.org/@dotnetthailand/gatsby-theme-minimal-portfolio (GET method), I got { "error": "Not found" }.
  • content of ~/.npmrc:
    //registry.npmjs.org/:_authToken=npm_mdxxxxxxxxx
    

aaronamm avatar Jan 05 '22 16:01 aaronamm

Adding my organisation name to the publishConfig field in package.json solved it for me as per the docs at https://docs.github.com/en/packages/quickstart

"publishConfig": { "@YOUR-USERNAME:registry": "https://npm.pkg.github.com" }

esdeh avatar Jan 08 '22 11:01 esdeh

What solved in my case was that i was using a nam different from the name of the organization. As soon as i solved thos issue the publishing went successfully

burgossrodrigo avatar Jan 13 '22 06:01 burgossrodrigo

I received a 404 until I provided a repository field in package.json when publishing to Github Packaages. Unhelpful error.

My goodness, why does this work?

liamfend avatar Mar 23 '22 08:03 liamfend

The note above @prisma%2ftemplates the escaped / was partially my issue. Not sure if what comes before is reserved in someway, but removing it then cleaning my pattern worked.

IntelliJ flagged me for the following
String violates the pattern: '^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$'

RichardTMiles avatar Apr 28 '22 15:04 RichardTMiles