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 #942

Open
shinokada opened this issue Sep 9, 2022 · 11 comments
Open

E404 Not Found #942

shinokada opened this issue Sep 9, 2022 · 11 comments

Comments

@shinokada
Copy link

shinokada commented Sep 9, 2022

Affected Packages

https://github.com/shinokada/svelte-heros-v2

Problem

git add .
git commit -m 'my message'
npx changeset

This works and I get a PR.

  1. Then I go to the repo and select Rebase and Merge on GitHub Pull request:

image

  1. Error

The GitHub action runs and return the following error:

...
...
> Using @sveltejs/adapter-node
  ✔ done
🦋  info npm info svelte-heros-v2
🦋  info svelte-heros-v2 is being published because our local version (0.4.1) has not been published on npm
🦋  info Publishing "svelte-heros-v2" at "0.4.1"
🦋  error an error occurred while publishing svelte-heros-v2: E404 Not Found - PUT https://registry.npmjs.org/svelte-heros-v2 - Not found 
🦋  error 
🦋  error  'svelte-heros-v2@0.4.1' is not in this registry.
🦋  error 
🦋  error Note that you can also install from a
🦋  error tarball, folder, http url, or git url.
🦋  error npm notice Publishing to https://registry.npmjs.org/
🦋  error npm ERR! code E404
🦋  error npm ERR! 404 Not Found - PUT https://registry.npmjs.org/svelte-heros-v2 - Not found
🦋  error npm ERR! 404 
🦋  error npm ERR! 404  'svelte-heros-v2@0.4.1' is not in this registry.
🦋  error npm ERR! 404 
🦋  error npm ERR! 404 Note that you can also install from a
🦋  error npm ERR! 404 tarball, folder, http url, or git url.
🦋  error {
🦋  error   "error": {
🦋  error     "code": "E404",
🦋  error     "summary": "Not Found - PUT https://registry.npmjs.org/svelte-heros-v2 - Not found",
🦋  error     "detail": "\n 'svelte-heros-v2@0.4.1' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
🦋  error   }
🦋  error }
🦋  error 
🦋  error npm ERR! A complete log of this run can be found in:
🦋  error npm ERR!     /home/runner/.npm/_logs/2022-09-09T01_49_08_107Z-debug-0.log
🦋  error 
🦋  error packages failed to publish:
🦋  svelte-heros-v2@0.4.1
Error: The process '/opt/hostedtoolcache/node/16.17.0/x64/bin/npm' failed with exit code 1
Error: The process '/opt/hostedtoolcache/node/16.17.0/x64/bin/npm' failed with exit code 1
    at m._setResult (/home/runner/work/_actions/changesets/action/v1/dist/index.js:102:[72](https://github.com/shinokada/svelte-heros-v2/runs/8261994145?check_suite_focus=true#step:6:73)58)
    at m.CheckComplete (/home/runner/work/_actions/changesets/action/v1/dist/index.js:102:66[86](https://github.com/shinokada/svelte-heros-v2/runs/8261994145?check_suite_focus=true#step:6:87))
    at ChildProcess.<anonymous> (/home/runner/work/_actions/changesets/action/v1/dist/index.js:102:5723)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:2[87](https://github.com/shinokada/svelte-heros-v2/runs/8261994145?check_suite_focus=true#step:6:88):5)

It says that E404 Not Found - PUT https://registry.npmjs.org/svelte-heros-v2, but it exists.

My release.yml:


  push:
    branhes: ['main']

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - run: npm i

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          registry-url: https://registry.npmjs.org/
      - name: install
        run: npm install

      - name: Create Release Pull Request or Publish to npm
        # https://github.com/changesets/action
        uses: changesets/action@v1
        with:
          # this expects you to have a script called release which does a build for your packages and calls changeset publish
          # release & version-packages:
          # "release": "npm run package && npx changeset publish",
          # "version-packages": "npx changeset version"
          version: npm run version-packages
          publish: npm run release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

I use changeset as followings in scripts, package.json:

 "release": "npm run build && npx changeset publish",
 "version-packages": "npx changeset version"

What am I doing wrong here?
I appreciate your inputs.

Proposed solution

Additional info

  1. I disabled Require two-factor authentication for write actions in NPM 2FA.

image

  1. My .npmrc according to https://docs.github.com/en/packages/quickstart
@shinokada:registry=https://npm.pkg.github.com
  1. I have the following in the package.json according to https://docs.github.com/en/packages/quickstart
	"publishConfig": {
		"@shinokada:registry": "https://npm.pkg.github.com"
	}
@Andarist
Copy link
Member

Andarist commented Sep 9, 2022

I was not aware of this syntax @USERNAME:registry and thus it might not be handled correctly - neither when we read the information from .npmrc and neither when we interpret package.json#publishConfig.

However, even despite those configurations, it seems that your package is being published to the default registry - perhaps because you specify it as the registry-url input to the actions/setup-node. Maybe this somehow leads to incorrect calls being made and to a confusing error.

However, this is still quite confusing because this package indeed exists in the queried registry. I'm not exactly sure what happens here.

A sideways question - are you sure that you actually want to publish this package to the GitHub Packages registry and not to the NPM registry?

@shinokada shinokada changed the title Not able to publish to NPM Not able to publish to NPM E404 Not Found Sep 9, 2022
@shinokada shinokada changed the title Not able to publish to NPM E404 Not Found E404 Not Found Sep 9, 2022
@shinokada
Copy link
Author

shinokada commented Sep 9, 2022

I didn't know that @USERNAME:registry and package.json#publishConfig are for GitHub packages and that was my mistake.

I removed them and added the following but it returns the same error:

- name: Creating .npmrc
        run: |
          cat << EOF > "$HOME/.npmrc"
            //registry.npmjs.org/:_authToken=$NPM_TOKEN
          EOF
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

@Andarist
Copy link
Member

Andarist commented Sep 9, 2022

I still don't understand why this error happens to you but one thing I've noticed is that you are outputting all build artifacts into another directory.

When doing so you probably should use this:

"publishConfig": {
  "dir": "./package"
}

@shinokada
Copy link
Author

shinokada commented Sep 9, 2022

Yes, Sveltekit requires svelte-package and outputs all to ./package.

Thanks. I will try it.

When i use standard-version, this is what I do:

standard-version && git push --follow-tags origin main && npm run package && cd package && npm publish && cd ..
  • standard-version: bump the version and update the Changelog according to the commit messages.
  • git push --follow-tags origin main: put to the github repo
  • npm run package: create a package
  • cd package: change dir to package
  • npm publish: publish to NPM
  • cd ..: return to the root dir.

@0xmaayan
Copy link

0xmaayan commented Dec 5, 2022

any updates here? I am having the same error

@Andarist
Copy link
Member

Andarist commented Dec 5, 2022

@0xmaayan this error most likely means that your .npmrc is misconfigured. I can't give you more concrete advice on how to fix this if you don't share a repro case.

@0xmaayan
Copy link

0xmaayan commented Dec 5, 2022

@Andarist thanks!
I am using a github workflow to publish packages that haven't created yet (i.e not on npmjs).

This is my .yaml workflow setup

name: Release

on:
  push:
    branches:
      - main

concurrency: ${{ github.workflow }}-${{ github.ref }}

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

    strategy:
      matrix:
        node-version: [16.x]

    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3

      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      - uses: pnpm/action-setup@v2
        name: Install pnpm
        id: pnpm-install
        with:
          version: 7
          run_install: false

      - name: Install Dependencies
        run: pnpm install --frozen-lockfile

      - name: Build global project
        run: pnpm run build

      - name: Create Release Pull Request or Publish to npm
        uses: changesets/action@v1
        with:
          publish: pnpm run publish-packages // runs changeset version && changeset publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

It creates a PR but then when merging it and trying to publish, it fails.
I tried with creating a .npmrc file action and without it - both output the same error.

I noticed that it fails for scoped packages (i.e @<org>/<name> format).

@nionis
Copy link

nionis commented Dec 29, 2022

Fails for my scoped packages too

@arthurfiorette
Copy link

@Andarist hey can you have a look at this? The problem is that changeset publish fails for scoped packages.
You can use this repo to see logs about.

@BrayhanV
Copy link

BrayhanV commented Oct 3, 2023

Some solution for this?

@arthurfiorette
Copy link

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

6 participants