Np: Publishing to github registry fails

Created on 26 Jun 2019  ·  12Comments  ·  Source: sindresorhus/np

Description

I just received access to the github package registry. When trying to use np it fails in the prerequisite stage:

  ❯ Prerequisite check
    ↓ Ping npm registry [skipped]
    ✔ Check npm version
    ✖ Verify user is authenticated
      → Command failed: npm access ls-collaborators @willsub/logger

When I try npm access ls-collaborators @willsub/logger from the CLI that fails because it's trying to access the npm registry and not the github registry.

Problem #1
It seems np is not picking up the custom registry, even though I have that specified both in .npmrc and in "publishConfig".

If I add --registry=https://npm.pkg.github.com to the npm access command line, it fails:

❯ npm access ls-packages @willsub --registry=https://npm.pkg.github.com
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/-/user/willsub/package?format=cli

Problem #2
It seems npm access is incompatible with the github registry. You might need to skip this step if the registry is github.

I do have the necessary config is my ~/.ssh/config.

Steps to reproduce

  1. Get access to the github package registry.
  2. Configure a project to use the github registry.
  3. Run np.

Expected behavior

I expect it to work as it does with the npm registry. Note that lerna was able to publish to the github registry successfully.

Environment

np - 5.0.3
Node.js - 12.4.0
npm - 6.9.1-next.0
Git - 2.22.0
OS - macOS 10.14.5

bug help wanted

Most helpful comment

433 dealt with the 2FA issue. I think np should be fully compatible with GitHub Package Registry now, though I have yet to try with the latest version.

All 12 comments

I ran into the same issue, without luck 😭

If you look at the code you can skip that pre-check by setting NODE_ENV=test (a quick source search told me that NODE_ENV seems to be used to skip that step only).

In my case npm publish failed after all the checks (I'll need to check the permissions), but this workaround may be helpful for you.

I'm just using npm version with a postversion script that commits and publishes.

I don't have access to the GitHub Package Registry, so I can't help much. But PRs are welcome to improve the situation.


It seems npm access is incompatible with the github registry. You might need to skip this step if the registry is github.

Please report this to the GitHub Package Registry team.

I've just published to GitHub using np 5.0.3. I did set up the scope beforehand, and had added publisherConfig to the package.json file.

Two observations:

  • You can't enable 2FA on the package. This step should be skipped.
  • GitHub automatically creates a tag on master. I think we should push tags before publishing.

Actually it looks like it always wants tags without v prefixes. Will see how / where I can ask about that and report back.

Actually it looks like it always wants tags without v prefixes. Will see how / where I can ask about that and report back.

I've been given to understand this will improve.

I don't have access to the GitHub Package Registry, so I can't help much. But PRs are welcome to improve the situation.

@sindresorhus we have access with our (private) organization; we wouldn't mind helping you out with a collaborator account if this would make testing easier.

Thanks, I have access now too, but I’ve had no time recently because of summer vacation.

Actually it looks like it always wants tags without v prefixes. Will see how / where I can ask about that and report back.

I've been given to understand this will improve.

https://github.blog/changelog/2019-09-06-publishing-a-package-no-longer-creates-a-release-and-other-github-package-registry-updates/

This leaves us with:

  • You can't enable 2FA on the package. This step should be skipped.

433 dealt with the 2FA issue. I think np should be fully compatible with GitHub Package Registry now, though I have yet to try with the latest version.

Can anyone confirm it works now? If so, we can document the support in the readme.

Yes this works, actually just published a package yesterday using:

$ np --version
5.1.3
Was this page helpful?
0 / 5 - 0 ratings