3

We're trying to use the Github Package Registry to publish our private org packages and they work/that bit is fine.

However, when we try to install them/use throughout our projects from the github registry alongside other scoped npm modules that are on the official npm registry, it will throw out something like:

error Couldn't find package "@azure/identity" on the "npm" registry.

I would have assumed this is not the desired behaviour as I can't imagine you'd want people to use github package registry without npm as an upstream in an 'A or B' kind of scenario. It is pointless not to be able to use dependenceis from NPM and GPR alongside each other.

My npmrc/yarnrc:

registry=https://npm.pkg.github.com/ORG_NAME

OR

registry=https://npm.pkg.github.com/

Verbose output reveals that it is indeed trying to get it from github.

  • Is there a correct configuration to be able to use GPR alongside NPM?
  • Is what I'm trying to do simply not possible with GPR and should I simply stick with NPM?
SebastianG
  • 8,563
  • 8
  • 47
  • 111

1 Answers1

4

You can define in your .npmrc file on which scope which repository should npm use.

@myscope:registry=https://npm.pkg.github.com

and for everything else

registry=https://registry.npmjs.org/

your .npmrc file should then look something like this:

@myscope:registry=https://npm.pkg.github.com
registry=https://registry.npmjs.org/
Mert
  • 1,333
  • 1
  • 12
  • 15
  • 1
    Thanks, this works with Yarn as well, the official docs syntax had the first line differently and afaik they have npm as a proxy for packages that are not scoped. But yarn is too dumb to work with those yet. – SebastianG Nov 20 '19 at 14:59
  • @MichaelB I had no luck making this work with Yarn. Would you mind sharing your solution? – Lucat Feb 03 '20 at 12:03
  • @Luke what context and what version of yarn are you using? is this purely for your local dev machine or somewhere in the cloud? Is the github package on a private repo or public? is it tied to an organisation or your own personal account? – SebastianG Feb 03 '20 at 12:22
  • I am trying to install private github packages via yarn during Travis ci build. npm works absolutely fine with npm token injection (although I had to make the env variable visibile even if it was on a private repo), yarn does not seem to honour npmrc nor yarnrc. My yarn version is 1.21.1 – Lucat Feb 03 '20 at 12:24