I’ve followed the instructions and still having no luck in installing private packages from a github registry during deployment builds.
The same .npmrc and private access token I’m using are working locally.
I’m even trying cat .npmrc at the beginning of my install command to debug whether or not the issue is with my NPM_RC env var configuration but the generated file is not there.
Running "install" command: `cat .npmrc && npm i`...
cat: .npmrc: No such file or directory
Error: Command "cat .npmrc && npm i" exited with 1
I expect the file to be there as per the documentation.
I’ve tried with and without the trailing slashes.
I’ve tried setting it through Terraform (Vercel API) and via the Vercel UI.
I’m attempting this on a preview deployment.
It’s worth noting that the branch I’m on used to have a .npmrc file committed which I then removed after I read the documentation of how to actually make this work on Vercel.
Thought I’d bring that up because I read a thread where someone mentioned that having the file already in your project could cause issues.
The issue you’re running into is most likely due to how the NPM_RC environment variable is being formatted. It needs to contain actual line breaks, not the literal \n characters.
A few things to double-check:
Use real newlines: In the Vercel Dashboard, press Enter to create actual line breaks inside the NPM_RC variable. Literal \n won’t work.
Swap out placeholders: Make sure {namespace} and {pak} are replaced with your actual GitHub org/username and your personal access token.
Start with a minimal config: Try testing with just the essentials to make sure the basics work:
Thanks for your reply and sorry for taking a while to respond, I have been away.
I managed to fix my issue! The problem I had was I was attempting to verify the existence of the generated .npmrc file during install using cat .npmrc && npm i.
This causes an error because, apparently, no such file exists. If I simply remove the cat command then everything works correctly.
I don’t know what Vercel is doing behind the scenes to make this work but I can’t complain too much.
It is slightly misleading that the documentation says a file is generated because we cannot verify its existence.
Anyway your suggested to use echo "$NPM_RC" made me remove the cat command which revealed that it was actually working, so thanks for that hahaha.