Managing multiple .npmrc

I followed this guide on the docs but it’s not working. I cheked that the .npmrc is created but npm does not seems to take it into acoount. If I just replace .npmrc.pages for .npmrc it works but I really needs this feature because husky fails with the config that I need.

I’m not sure exactly as to why this is needed. Could you please explain the problem you’re trying to solve?

We have a private dependency that is hosted in a Gitlab repository through their packages registries functionality. For this to work on Cloudflare pages I need to set a .npmrc, in my case this is the format.


The thing is that if a I keep this file, every command like yarn build or yarn install fails if you don’t have TOKEN env variable defined. Every developer has this repository configured in npm globally with their own access tokens and I want to keep it like that. In fact I’m surprised because you have a solution in the docs but I could not fin a way to make it work. It seems for me that it does not matter if you perform actions over .npmrc on the preinstall hooks because npm already locked up the state in which it is going to operate.

The thing that I want to know if why the example that is written in the docs does not seems to work. and if the ir another workaround.