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

E404 Not Found - PUT for published packages #98

Closed
talentlessguy opened this issue Jul 7, 2021 · 11 comments · Fixed by pantheon-systems/decoupled-kit-js#612
Closed

Comments

@talentlessguy
Copy link

I'm using changesets github action to publish packages after running changesets version locally.

This is what I have in my github actions:

- name: Create Release Pull Request or Publish to npm
  id: changesets
  uses: changesets/action@master
  with:
    # This expects you to have a script called release which does a build for your packages and calls changeset publish
    publish: pnpm release
    commit: "chore: release"
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

this is what I get in actions logs:

🦋  error an error occurred while publishing @tinyhttp/ip-filter: E404 Not Found - PUT https://registry.npmjs.org/@tinyhttp%2fip-filter - Not found 
🦋  error 
🦋  error  '@tinyhttp/ip-filter@1.3.12' is not in the npm registry.
🦋  error You should bug the author to publish it (or use the name yourself!)
🦋  error 
🦋  error Note that you can also install from a
🦋  error tarball, folder, http url, or git url.
🦋  error an error occurred while publishing @tinyhttp/app: E404 Not Found - PUT https://registry.npmjs.org/@tinyhttp%2fapp - Not found 
🦋  error 
🦋  error  '@tinyhttp/app@1.3.12' is not in the npm registry.
🦋  error You should bug the author to publish it (or use the name yourself!)
🦋  error 
🦋  error Note that you can also install from a
🦋  error tarball, folder, http url, or git url.
🦋  error an error occurred while publishing @tinyhttp/unless: E404 Not Found - PUT https://registry.npmjs.org/@tinyhttp%2funless - Not found 
🦋  error 
🦋  error  '@tinyhttp/unless@1.3.12' is not in the npm registry.
🦋  error You should bug the author to publish it (or use the name yourself!)
🦋  error 
🦋  error Note that you can also install from a
🦋  error tarball, folder, http url, or git url.
🦋  error packages failed to publish:
🦋  @tinyhttp/app@1.3.12
🦋  @tinyhttp/ip-filter@1.3.12
🦋  @tinyhttp/unless@1.3.12
 ERROR  Command failed with exit code 1.
Error: The process '/home/runner/setup-pnpm/node_modules/.bin/pnpm' failed with exit code 1
    at a._setResult (/home/runner/work/_actions/changesets/action/master/dist/index.js:86:6638)
Error: The process '/home/runner/setup-pnpm/node_modules/.bin/pnpm' failed with exit code 1
    at a.CheckComplete (/home/runner/work/_actions/changesets/action/master/dist/index.js:86:6068)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/changesets/action/master/dist/index.js:86:5102)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

When I run pnpm release locally, it runs just fine

@zuhair-naqvi
Copy link

Same here, any updates on this?

@zuhair-naqvi
Copy link

zuhair-naqvi commented Jul 30, 2021

Found the answer:

  1. You need to ensure you create an environment, add your NPM_TOKEN as a secret to that environment, set environment: YOUR_ENV_NAME in your release workflow.

  2. Add the following step before changesets action:

  run: |
    cat << EOF > "$HOME/.npmrc"
      email=my@email.com
      //registry.npmjs.org/:_authToken=$NPM_TOKEN
    EOF
  env:
    NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

@estrattonbailey
Copy link

+1, seeing the same issue. Creating an .npmrc as suggested here (and elsewhere) hasn't worked for me, unfortunately.

Afaict, the main outlier between my use case (and talentlessguy's) is usage of pnpm for dependencies. Could that be the culprit?

@estrattonbailey
Copy link

Just following up: I was able to get this working.

I had tried a few methods of creating an .npmrc on the fly a while back, but either it truly didn't work or I messed something up. Anyway, finally got back to this and noticed that pnpm updated their docs for usage with Changesets, so I gave it another go.

I ended up creating and commiting an .npmrc to my repo, as per pnpm docs:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

However, this may be a real bug in the Changesets action, since the README here states that it outputs a .npmrc file. I tested this and saw that it doesn't work unless I create an .npmrc myself.

Here's essentially the workflow I ended up with (including .npmrc in the root):

name: CD

on:
  push:
    branches:
      - main

env:
  PNPM_CACHE_FOLDER: .pnpm-store
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest

    steps:
      # env stuff
      - name: checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: node - setup
        uses: actions/setup-node@v2
        with:
          node-version: 14.x

      # pnpm stuff
      - name: pnpm - install
        run: npm i pnpm@latest -g
      - name: pnpm - config
        run: pnpm config set store-dir $PNPM_CACHE_FOLDER
      - name: pnpm - install
        run: pnpm install

      # build
      - name: build
        run: pnpm build

      # publish to npm
      - name: release
        id: changesets
        uses: changesets/action@master
        with:
          publish: pnpm release
          version: pnpm version-packages
          commit: 'chore: version packages'
          title: 'chore: version packages'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@Andarist
Copy link
Member

Hm, the problem seems to be that .npmrc was already existing and it was found by the action (info about it can be found in the log of the action):

action/src/index.ts

Lines 45 to 47 in c3d8827

let npmrcPath = `${process.env.HOME}/.npmrc`;
if (fs.existsSync(npmrcPath)) {
console.log("Found existing .npmrc file");

I'll try to take a look at actions preceding it to see if it got created there or what is happening here. And I'll try to think about how we should handle this.

@estrattonbailey
Copy link

Ah, you're right, I totally missed that log. It's probably pnpm creating one with pnpm config set, which must shadow npm config set.

@Andarist
Copy link
Member

I've created a PR that, hopefully, should help with this problem: #110

@Andarist
Copy link
Member

Andarist commented Nov 9, 2021

The improvement from the commit above has landed. This should fix the @estrattonbailey's problem and hopefully, it should also fix the OP's problem.

If you bump into any more issues - please open a new thread with a repro case.

@Andarist Andarist closed this as completed Nov 9, 2021
@nhhockeyplayer
Copy link

nhhockeyplayer commented Aug 4, 2022

well yeah... someone forgot to fix the manual terminal command line way

npm publish --registry https://npm.pkg.github.com/ --no-git-tag-version --no-push --yes

this is the worst implementation I have ever seen

npm notice Publishing to https://npm.pkg.github.com/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://npm.pkg.github.com/@meanstacknh%2fshared-root-ui-styles - The expected resource was not found.
npm ERR! 404 
npm ERR! 404  '@meanstacknh/shared-root-ui-styles@0.0.0' is not in this registry.

@Andarist
Copy link
Member

Andarist commented Aug 5, 2022

@nhhockeyplayer Could you rephrase? I don't know if you are reporting a new issue, posting a workaround, or just blaming npm's CLI for something or blaming Changesets for something.

@vaynevayne
Copy link

vaynevayne commented May 21, 2023

hello, @Andarist excuse me, When executing locally, you need a npmToken in npmrc, right?
If I don't have a npmToken, can I do npm login -> changget push?

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

Successfully merging a pull request may close this issue.

6 participants