Skip to content

[Pages] remove non working private packages section npm-private-registry.md - #1334

Closed
mckalexee wants to merge 1 commit into
cloudflare:productionfrom
mckalexee:patch-2
Closed

[Pages] remove non working private packages section npm-private-registry.md#1334
mckalexee wants to merge 1 commit into
cloudflare:productionfrom
mckalexee:patch-2

Conversation

@mckalexee

Copy link
Copy Markdown
  • While this section does work when testing locally, it does not appear to work correctly when actually deploying with CloudFlare Pages.
  • Since this does not function correctly, I've removed it from the documentation to avoid further confusion.

Steps to Reproduce

  • Create the .npmrc.pages file following the guide here, and modified the preinstall script for the package.json according to the guide.

Here's the .npmrc.pages file that I used. my_org was actually the organization that I have private packages installed.

//npm.pkg.github.com/:_authToken=${TOKEN_FOR_GITHUB}
@my_org:registry=https://npm.pkg.github.com/my_org
  • Create the token used for TOKEN_FOR_GITHUB and load it into CloudFlare Pages.

  • Verify running this locally correctly moes the .npmrc.pages file and installs packages.

  • Deploy to CloudFlare pages
    I received this error during the Building Application process

13:05:36.876	npm ERR! code E401
13:05:36.878	npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"

I manually copied over the .npmrc.pages file to .npmrc, committed the results, and re-deployed. This time the deployment was successful.

The conclusion here is that modifying the .npmrc in CloudFlare Pages using the preinstall is not a functional way to authenticate private registries, and CloudFlare Pages will need to make some changes on their side to support private registries.

Using //npm.pkg.github.com/:_authToken=${TOKEN_FOR_GITHUB} in the .npmrc currently is not tenable due to the fact that it breaks all local development environments.

While this section does work when testing locally, it does not appear to work correctly when actually deploying with CloudFlare Pages.

After the initial `npm install` process is started inside CloudFlare any changes to the `.npmrc` file do not appear to be respected.

## Steps to Reproduce

I created the `.npmrc.pages` file following the guide here, and modified the `preinstall` script for the `package.json` according to the guide.

Here's the `.npmrc.pages` file that I used. `my_org` was actually the organization that I have private packages installed.
```
//npm.pkg.github.com/:_authToken=${TOKEN_FOR_GITHUB}
@my_org:registry=https://npm.pkg.github.com/my_org
```

I created and tested the token used for `TOKEN_FOR_GITHUB` and loaded it into CloudFlare Pages. 

I verified that running this locally correctly moved the `.npmrc.pages` file and installed packages.

I deployed to CloudFlare pages and received this error during the Building Application process
```
13:05:36.876	npm ERR! code E401
13:05:36.878	npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
```

I manually copied over the  `.npmrc.pages` file to `.npmrc`, committed the results, and re-deployed. This time the deployment was successful. 

The conclusion here is that modifying the `.npmrc` in CloudFlare Pages using the `preinstall` is not a functional way to authenticate private registries, and CloudFlare Pages will need to make some changes on their side to support private registries. 

Using `//npm.pkg.github.com/:_authToken=${TOKEN_FOR_GITHUB}` in the `.npmrc` currently is not tenable due to the fact that it breaks all local development environments.
@mckalexee
mckalexee requested a review from a team May 12, 2021 17:33
@mckalexee
mckalexee requested a review from a team as a code owner May 12, 2021 17:33
@mckalexee

Copy link
Copy Markdown
Author

@lukeed It looks like you previously added this documentation.

I wanted to tag you here just to make sure I'm not missing something, or to see if you were able to get this to work.

Thanks!

@lukeed

lukeed commented Jun 4, 2021

Copy link
Copy Markdown
Contributor

Hey there, did you end up getting this working? Not sure if I was speaking with you or someone else on Discord, but this appears (or was) a GitHub Token permission issue.

@lukeed

lukeed commented Jul 15, 2021

Copy link
Copy Markdown
Contributor

Closing this as it looks to be an issue w/ GitHub token permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants