Unable to access private github package with yarn during pages build

Hi,

I have a Cloudflare pages app that is built automatically from changes to github, unfortunately after I’ve added use of private npm package, yarn install no longer works.

I’ve followed the article here - Install private packages · Cloudflare Pages docs

Then following info is provided as part of preinstall (with removed tokens and private package name).

Wonder if anyone else have a resolution to such an issue ?

22:05:21.662	info yarn config
22:05:21.664	{
22:05:21.664	  'version-tag-prefix': 'v',
22:05:21.664	  'version-git-tag': true,
22:05:21.664	  'version-commit-hooks': true,
22:05:21.664	  'version-git-sign': false,
22:05:21.664	  'version-git-message': 'v%s',
22:05:21.664	  'init-version': '1.0.0',
22:05:21.664	  'init-license': 'MIT',
22:05:21.664	  'save-prefix': '^',
22:05:21.664	  'bin-links': true,
22:05:21.664	  'ignore-scripts': false,
22:05:21.664	  'ignore-optional': false,
22:05:21.664	  registry: 'https://registry.yarnpkg.com',
22:05:21.664	  'strict-ssl': true,
22:05:21.664	  'user-agent': 'yarn/1.22.10 npm/? node/v15.14.0 linux x64',
22:05:21.664	  version: '1.22.10'
22:05:21.664	}
22:05:21.664	info npm config
22:05:21.664	{
22:05:21.664	  tmp: '/opt/buildhome/tmp',
22:05:21.664	  'always-auth': true,
22:05:21.664	  registry: 'https://registry.yarnpkg.com',
22:05:21.664	  '@<private package>:registry': 'https://npm.pkg.github.com',
22:05:21.664	  '//npm.pkg.github.com/:_authToken': '<token that works locally>',
22:05:21.664	  version: '1.22.10',
22:05:21.664	  'version-commit-hooks': true,
22:05:21.664	  'user-agent': 'yarn/1.22.10 npm/? node/v15.14.0 linux x64',
22:05:21.664	  'bin-links': true,
22:05:21.664	  'init-version': '1.0.0',
22:05:21.664	  'init-license': 'MIT',
22:05:21.664	  'version-tag-prefix': 'v',
22:05:21.665	  'ignore-scripts': '',
22:05:21.665	  'version-git-message': 'v%s',
22:05:21.665	  argv: '{"remain":[],"cooked":["install"],"original":["install","--cache-folder","/opt/buildhome/.yarn_cache"]}',
22:05:21.665	  'version-git-tag': true,
22:05:21.665	  'version-git-sign': '',
22:05:21.665	  'strict-ssl': true,
22:05:21.665	  '_<private package>-registry': 'https://npm.pkg.github.com',
22:05:21.665	  'save-prefix': '^',
22:05:21.665	  'ignore-optional': ''
22:05:21.665	}
22:05:21.665	Done in 0.06s.
22:05:21.680	[1/4] Resolving packages...
22:05:21.908	[2/4] Fetching packages...
22:05:28.803	error An unexpected error occurred: "https://npm.pkg.github.com/download/@<private package>/1.4.0/b5ce33967a45ccb74f59b7abe795ed4706612989b53712d0bd2e9f529f006b98: Request failed \"401 Unauthorized\"".
22:05:28.803	info If you think this is a bug, please open a bug report with the information provided in "/opt/buildhome/repo/yarn-error.log".
1 Like

I have the same issue. Anyone know of a solution?

This also happens to me,

It seems always trying to connect to https://registry.yarnpkg.com/ when using yarn

and not respect the settings inside .npmrc file, which is

@muyantech:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=<token>

The two packages in package.json are

    "@muyantech/ckeditor5": "^0.0.1",
    "@muyantech/gantt-task-react": "^0.0.1-alpha-v6",

I assume it should connect to npm.pkg.github.com to retrieve the packages, but actually it doesn’t.

Does anyone knows how to resolve this? thanks very much :slight_smile:

Hello,

I was able to resolve this issue by not using cloudflare builders. Instead I opted to generate static site on github actions, then push it into “github” publish repo, which on push will trigger cloudflare static site deploy.

Also, there were other issues with cloudflare builders that they would take random amount of time to clone repo, resulting in timeouts, and by changing deploy model it was completely removed.

With regards,
Ignat Zapolsky