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

Can't publish packages to other registry than npm registry #20919

Closed
1 of 4 tasks
guysenpai opened this issue Dec 25, 2023 · 8 comments · Fixed by #20995
Closed
1 of 4 tasks

Can't publish packages to other registry than npm registry #20919

guysenpai opened this issue Dec 25, 2023 · 8 comments · Fixed by #20995
Assignees

Comments

@guysenpai
Copy link
Contributor

Current Behavior

When try to first publish a lib on github packages registry (https://npm.pkg.github.com/), the publish failed because of error in npm view {package} versions dist-tags --json --registry=https://npm.pkg.github.com/ command

Expected Behavior

first publish on github packages registry don't fail

GitHub Repo

No response

Steps to Reproduce

Nx Report

Node   : 20.10.0
   OS     : linux-x64
   pnpm   : 8.11.0
   
   nx                 : 17.2.7
   @nx/js             : 17.2.7
   @nx/jest           : 17.2.7
   @nx/linter         : 17.2.7
   @nx/eslint         : 17.2.7
   @nx/workspace      : 17.2.7
   @nx/angular        : 17.2.7
   @nx/cypress        : 17.2.7
   @nx/devkit         : 17.2.7
   @nx/esbuild        : 17.2.7
   @nx/eslint-plugin  : 17.2.7
   @nrwl/tao          : 17.2.7
   @nx/web            : 17.2.7
   @nx/webpack        : 17.2.7
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @nx-aws-plugin/nx-aws-cache : 3.2.0

Failure Logs

> nx run secure-storage:nx-release-publish

Something unexpected went wrong when checking for existing dist-tags.
 Error: Command failed: npm view @afrogeeksland/secure-storage versions dist-tags --json --registry=https://npm.pkg.github.com/
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/@afrogeeksland%2fsecure-storage - npm package "secure-storage" does not exist under owner "afrogeeksland"
npm ERR! 404 
npm ERR! 404  '@afrogeeksland/secure-storage@*' 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: /home/runner/.npm/_logs/2023-12-24T14_48_49_665Z-debug-0.log

    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at runExecutor (/home/runner/work/packages/packages/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@nx/js/src/executors/release-publish/release-publish.impl.js:71:57)
    at runExecutorInternal (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/run/run.js:73:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/runner/work/packages/packages/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/run/run.js:155:44
    at async handleErrors (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/utils/params.js:9:16)
    at async process.<anonymous> (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/bin/run-executor.js:59:28) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 7b 0a 20 20 22 65 72 72 6f 72 22 3a 20 7b 0a 20 20 20 20 22 63 6f 64 65 22 3a 20 22 45 34 30 34 22 2c 0a 20 20 20 20 22 73 75 6d 6d 61 72 79 22 3a 20 ... 321 more bytes>,
    <Buffer 6e 70 6d 20 45 52 52 21 20 63 6f 64 65 20 45 34 30 34 0a 6e 70 6d 20 45 52 52 21 20 34 30 34 20 4e 6f 74 20 46 6f 75 6e 64 20 2d 20 47 45 54 20 68 74 ... 450 more bytes>
  ],
  pid: 1926,
  stdout: <Buffer 7b 0a 20 20 22 65 72 72 6f 72 22 3a 20 7b 0a 20 20 20 20 22 63 6f 64 65 22 3a 20 22 45 34 30 34 22 2c 0a 20 20 20 20 22 73 75 6d 6d 61 72 79 22 3a 20 ... 321 more bytes>,
  stderr: <Buffer 6e 70 6d 20 45 52 52 21 20 63 6f 64 65 20 45 34 30 34 0a 6e 70 6d 20 45 52 52 21 20 34 30 34 20 4e 6f 74 20 46 6f 75 6e 64 20 2d 20 47 45 54 20 68 74 ... 450 more bytes>
}

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@guysenpai guysenpai changed the title Can't publish to github packages registry Can't publish packages to other registry than npm registry Dec 25, 2023
@guysenpai
Copy link
Contributor Author

guysenpai commented Dec 25, 2023

I've tried to configure an aws codeartifact registry but I always have an error on the same command:
npm view {package} versions dist-tags --json --registry={registry_url} .

I think the code below limits the publishing to npm registry

if (
        !(
          stdoutData.error?.code?.includes('E404') &&
          stdoutData.error?.summary?.includes('no such package available')
        ) &&
        !(
          err.stderr?.toString().includes('E404') &&
          err.stderr?.toString().includes('no such package available')
        )
      ) {
        console.error(
          `Something unexpected went wrong when checking for existing dist-tags.\n`,
          err
        );
        return {
          success: false,
        };
      }

For other registry like github package registry or a codeartifact we have differents 404 error messages

  • Github package registry : npm package "{package}" does not exist under owner "{scope}" for @scope/package library to publish
  • Codeartifact: Package, '{packageName}', not found. for @scope/package as packageName to publish

@thdk
Copy link
Contributor

thdk commented Dec 25, 2023

I can also confirm the issue when trying to publish to a registry hosted by JFrog Artifactory.
Adding my logs here in case in helps determining a generic solution.

Waiting for the debugger to disconnect...
Something unexpected went wrong when checking for existing dist-tags.
 Error: Command failed: npm view @scope/package versions dist-tags --json
Debugger attached.
npm ERR! code E404
npm ERR! 404 Not Found - GET https://xyx.jfrog.io/artifactory/api/npm/npm-virtual/@scope%2fpackage - not_found
npm ERR! 404 
npm ERR! 404  '@scope/package@*' 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.

Maybe an additional prompt could be added in this scenario?

Couldn't find this package in the registry, is this the first time you publish this package? y/N

workaround:

Publish the first version manually by using the publish script in {workspaceRoot}/tools/scripts/publish.mjs}:

node tools/scripts/publish.mjs [package-name] [0.1.0] latest

@thdk
Copy link
Contributor

thdk commented Dec 26, 2023

Duplicate of #19971

@jaysoo jaysoo added the scope: misc Misc issues label Dec 27, 2023
@JamesHenry
Copy link
Collaborator

@thdk This doesn't actually look like a duplicate of that issue. This relates to publishing, that other issue relates to versioning.

As others have pointed out, this seems to be more to do with how we inspect the error messages from the npm CLI when publishing and how for non-npm registries the output is subtly different.

@JamesHenry JamesHenry assigned fahslaj and unassigned JamesHenry Jan 3, 2024
@Charuta-Chaudhari
Copy link

Can we publish to Gitlab private registry using npm release publish --resgistry=https://gitlab.com/?

There seems to be no clear documentation around it. If it is a private repository where should I specify the access token?

I am stuck at this point so was wondering how we can do it. Thanks for the great work you all are doing!

@JamesHenry
Copy link
Collaborator

@Charuta-Chaudhari That is not related to this issue. Please use the discord for asking for help: https://go.nx.dev/community

(However, the quick answer is that the standard .npmrc file settings will all be respected, so you can set your auth token in there exactly how you would for using the npm publish CLI directly)


I believe we can say that the common entry in the error between all the listed systems in the combination of 404 and Not Found in the error (sometimes in that casing, sometimes lower case). Therefore, hopefully #20995 should fix this issue.

@Charuta-Chaudhari
Copy link

@JamesHenry Thanks you so much for quick response. It helped. Also, thank you for pointing to community channel. I was not aware of it.

Copy link

github-actions bot commented Feb 4, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants