Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm publish 404 Not Found - PUT #1637

Closed
1000i100 opened this issue Aug 7, 2020 · 41 comments
Closed

npm publish 404 Not Found - PUT #1637

1000i100 opened this issue Aug 7, 2020 · 41 comments

Comments

@1000i100
Copy link

1000i100 commented Aug 7, 2020

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  'g1link@0.1.1' 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 1000i100 changed the title [BUG] <title> npm publish 404 Not Found - PUT Aug 7, 2020
@maxsmaleha
Copy link

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

@tschaub
Copy link

tschaub commented Aug 20, 2020

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 mock-fs@4.13.0
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 'mock-fs@4.13.0' 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 ]

@maxsmaleha
Copy link

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.

@burtonator
Copy link

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.

@ljharb
Copy link
Collaborator

ljharb commented Nov 29, 2020

Have you tried with npm 7?

@burtonator
Copy link

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

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Jan 25, 2021

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: Maxim-Mazurok/google-api-typings-generator#418

Using npm v6.14.10

@1000i100
Copy link
Author

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.

@1nVitr0
Copy link

1nVitr0 commented Mar 14, 2021

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.

@sleshJdev
Copy link

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

@clok
Copy link

clok commented Mar 18, 2021

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.

@wiasliaw
Copy link

wiasliaw commented Mar 22, 2021

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

@bdefore
Copy link

bdefore commented Jul 21, 2021

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

@esdeh
Copy link

esdeh commented Jan 8, 2022

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

@burgossrodrigo
Copy link

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

@liamfend
Copy link

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?

@RichardTMiles
Copy link

RichardTMiles commented Apr 28, 2022

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-._~]*$'

@rgparkins
Copy link

I had this issue.. Turned out I have renamed the repo and although there are redirects in place to view code etc you do need the updated repo name in order to publish into the package repository

@ChristianGrete0770
Copy link

Hi @rgparkins, we do have the same issue at the moment. After renaming our repository, publishing fails both locally and in GitHub workflows. Could you please give us more details on how you fixed that issue? We updated every occurrence of the old repo URL but still getting this problem...

@13twelve
Copy link

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 did you ever figure this out?

@13twelve
Copy link

I was having the E404 error:

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

With the %2f in the URL. I tried npm login and npm adduser and changing the registry url, deleting the .npmrc, making new access tokens, changing my email address, updating my machine and everything else I could see here and on stack overflow.

In the end the fix seemed to be making a new "team" in the organisation and assigning myself and my package to this.
My guess is that my NPM organisation requires users to have 2FA on and two users assigned to the 'developers' group didn't have this on.

@nhhockeyplayer
Copy link

nhhockeyplayer commented Aug 5, 2022

This continues to be a serious show stopping issue
after repeated login/logout or .npmrc or no .npmrc

GITHUB PLZ TAKE NOTICE

all publishing is halted and broken at this time

npm notice === Tarball Details === 
npm notice name:          @nhhockeyplayer/shared-root-ui-styles          
npm notice version:       0.0.0                                          
npm notice filename:      @nhhockeyplayer/shared-root-ui-styles-0.0.0.tgz
npm notice package size:  79.2 kB                                        
npm notice unpacked size: 474.2 kB                                       
npm notice shasum:        3c0cf14ac85c2461e3ca46695355f24485b66ae6       
npm notice integrity:     sha512-hI5pXNU0aVpJ+[...]PX6xB5i/R3GeA==       
npm notice total files:   80                                             
npm notice 
npm notice Publishing to https://npm.pkg.github.com/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@nhhockeyplayer%2fshared-root-ui-styles - The expected resource was not found.
npm ERR! 404 
npm ERR! 404  '@nhhockeyplayer/shared-root-ui-styles@0.0.0' is not in this registry.
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!     /Users/meanstack02/.npm/_logs/2022-08-05T17_41_30_858Z-debug-0.log

@noherczeg
Copy link

In my case the problem was that I had multiple .npmrc files in a monorepo. Removing all these files fixed it for a manual publish. I was logged in with a user who was a member of the organization under which I had the scope.

Running npm whoami must work. If it doesn't then your publish will never work.

@MrsSima
Copy link

MrsSima commented Sep 4, 2022

Had my problem because of 'name' in package.json as just repo name, not @YOUR-USERNAME/YOUR-REPOSITORY
So adding username solved the issue.
Not a documentation problem, but be careful

@LucasZheng
Copy link

Same issue, have tried all the solutions above, not work.

@CatChen
Copy link

CatChen commented Oct 17, 2022

This is what works for me:

  1. Create the .npmrc file in the project directory if it doesn't exist.
  2. Add always-auth = true to .npmrc.

How I found out:

  1. Run npm config ls -l locally to see what configs I have on top of the default values.
  2. Add npm config ls -l to the GitHub Workflow to see what configs the runner has.
  3. It turns out GitHub Action runner adds always-auth = false to its user level .npmrc.

@RootDev4
Copy link

Had my problem because of 'name' in package.json as just repo name, not @YOUR-USERNAME/YOUR-REPOSITORY So adding username solved the issue. Not a documentation problem, but be careful

I've got this "E404 Not Found" and "is not in registry" error too so I tried this and it worked for me. My original repository name (without @USERNAME/ in front of it) seemed to be already taken, although there were no search results on npmjs.com for my repository name. After changing my repository name to another, it worked with npm login and npm publish --access public.
So check your repository name and try it with other names or add some numbers at the end for testing purposes.

@rgparkins
Copy link

Hi @rgparkins, we do have the same issue at the moment. After renaming our repository, publishing fails both locally and in GitHub workflows. Could you please give us more details on how you fixed that issue? We updated every occurrence of the old repo URL but still getting this problem...

@RootDev4 sorry I missed you message... have a look at our repo, it may help

https://github.com/talentconsulting/engineering.apickli

@LordlyCat
Copy link

check your publishConfig

davidtaing added a commit to davidtaing/map-immute that referenced this issue Feb 25, 2023
Hopefully this fixes the NPM Publish workflow failing due to a 404 error.

npm/cli#1637 (comment)
@helbing
Copy link

helbing commented Apr 13, 2023

Same issue. I found the reason. In npm version 2 or greater, if your package is the prefix @, e.g. @thisisscope/packagename, it means that you need to create the npm organization which is named thisisscope in this sample, and you need to generate an access token which has permission with this scope.

https://docs.npmjs.com/about-scopes
https://docs.npmjs.com/creating-and-publishing-scoped-public-packages
https://www.npmjs.com/org/create

@hozzijeong
Copy link

Had my problem because of 'name' in package.json as just repo name, not @YOUR-USERNAME/YOUR-REPOSITORY So adding username solved the issue. Not a documentation problem, but be careful

you saved my day 👍👍👍

@pablomendezroyo
Copy link

This unhelpful error is also thrown for wrong credentials, double check the token you have set in the GitHub secrets. My issue was that I was setting the token without the prefix npm_

@mitch1009
Copy link

This mad error gave me headache for hours till i abruptly changed my repository name yo username/lib-name i don't know why but this works form me.

@RichEwin
Copy link

RichEwin commented Aug 7, 2023

Adding to this. I had the same problem in my github actions pipeline ( 404 Not Found ) and it was due to me not using the correct npm secret.

@tenadolanter
Copy link

tenadolanter commented Dec 12, 2023

change .yml config from

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - run: git checkout $CI_COMMIT_REF_NAME
      - run: npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
      - run: npm config set scope "@tenado"
      - run: SPACE_CHAR=" "
      - run: npx standard-version --releaseCommitMessageFormat "chore(release):${SPACE_CHAR}{{currentTag}}"
      - run: git push --follow-tags origin $CI_COMMIT_REF_NAME
      - run:  npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}

to

 publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - run:  |
          git checkout $CI_COMMIT_REF_NAME
          npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
          npm config set scope "@tenado"
          SPACE_CHAR=" "
          npx standard-version --releaseCommitMessageFormat "chore(release):${SPACE_CHAR}{{currentTag}}"
          git push --follow-tags origin $CI_COMMIT_REF_NAME
          npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}

then, you can publish success~

hellohublot added a commit to OneKeyHQ/react-native-lite-card that referenced this issue Dec 29, 2023
@receter
Copy link

receter commented Jan 12, 2024

It looks like I ran into this issue because I used the env var NPM_TOKEN instead of NODE_AUTH_TOKEN in a GitHub action that runs on release created.

did not work:

      - name: Publish 🚀
        shell: bash
        run: pnpm publish packages/components --access public --no-git-checks
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

works:

      - name: Publish 🚀
        shell: bash
        run: pnpm publish packages/components --access public --no-git-checks
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

@wilsonloo
Copy link

changing field name in package.json from "test_verdaccio" to "testverdaccio", works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests