Next.js Discord

Discord Forum

Private github package

Unanswered
Yacare Caiman posted this in #help-forum
Open in Discord
Yacare CaimanOP
These [docs](https://vercel.com/guides/using-private-dependencies-with-vercel) refer to "package-name": "git+https://.... Where is that set? In package.json, .npmrc, elsewhere? If it is package.json, that is a problem since it is source controlled and would have a token stored in it.

I'm trying to allow my Vercel project to access a private npm package hosted on github that I have a token for accessing.

11 Replies

It depends on how you set up your package, most should work with just npm i @package/name if the npmrc is present. If you add the NPM_TOKEN env it'll generate the npmrc needed during CI for you
@Marchy It depends on how you set up your package, most should work with just `npm i @package/name` if the npmrc is present. If you add the NPM_TOKEN env it'll generate the npmrc needed during CI for you
Yacare CaimanOP
And NPM_TOKEN environment variable is only for npmjs.org, yes? If I want another repo for private package, not npmjs.org, but like github (or technically, in addition to public npmjs.org packages), I need NPM_RC environment variable that has two lines...
//registry.npmjs.org/:_authToken=<MY TOKEN FOR GITHUB>
//npm.pkg.github.com

Is that correct?
Depends on where your package is published, but yes. Not sure if that'll point to npm or github registries.
so either that way or
//registry.npmjs.org
//npm.pkg.github.com/:_authToken=TOKEN_FOR_GITHUB
@Marchy Depends on where your package is published, but yes. Not sure if that'll point to npm or github registries.
Yacare CaimanOP
ahh, right. So it tries npmjs first, then github if it can't find it there.
Well, it still needs to point to the npm registry for other packages
so yeah
Yacare CaimanOP
Got it. Thanks. I'll give that a try.
Once you publish your private package, it should give you installation instructions
then it's just adding the right token to your env in vercel and it'll take care of it
Yacare CaimanOP
I've published and installed in my local instance. But when deploying to vercel, fails at npm i, which lead me to the docs.