.npmrc file and cloudflare pages

Hi guys I have a question when using npm private packages and then deploying to cloudflare pages. In my project I have the two files: .npmrc and .npmrc.pages. In the .npmrc config I have this record: //registry.npmjs.org/:_authToken=$NPM_TOKEN; And in the .npmrc.pages: //registry.npmjs.org/:_authToken=${NPM_TOKEN}. In local development everything works correctly but when I try to deploy to pages it tells me that the private packages do not exist. In the config of my cloudflare project I have a env which is NPM_CONFIG_USERCONFIG = /opt/buildhome/repo/.npmrc.pages
10 Replies
NastykSwED
NastykSwED15mo ago
And of course I have my .env file; I forgot to mention that if I put the brackets in the env in the .npmrc file when I build the project I get an error about private packages not found. By not using the brackets it works correctly
James
James15mo ago
Do you have the NPM_TOKEN env var defined in your build environment on Pages? For me, it was as simple as adding an .npmrc.pages with //registry.npmjs.org/:_authToken=${NPM_TOKEN}, NPM_CONFIG_USERCONFIG = /opt/buildhome/repo/.npmrc.pages, and then a read-only token as NPM_TOKEN
NastykSwED
NastykSwED15mo ago
yes,i have both the token and the url of the .npmrc.pages path in my project's env. I have done all the steps in the cloudflare documentation.
NastykSwED
NastykSwED15mo ago
NastykSwED
NastykSwED15mo ago
NastykSwED
NastykSwED15mo ago
James
James15mo ago
Oh are you using yarn to install packages? The instructions are purely for npm Yarn has its own config with .yarnrc I believe - you'll want to do a similar config for that if you're using yarn
NastykSwED
NastykSwED15mo ago
uuuh my boy, then I should create both ..yarnrc and .yarnrc.pages, right?
James
James15mo ago
I'm not familiar with yarn, but yeah you'll probably need to do something like that, and figure out what the NPM_CONFIG_USERCONFIG equivalent is for yarn And the syntax for .yarnrc too - I doubt it's the same as the .npmrc one
NastykSwED
NastykSwED15mo ago
Okya, thax mate
Want results from more Discord servers?
Add your server