How to install private github repo in vercel
Unanswered
Cinnamon posted this in #help-forum
CinnamonOP
I'm trying to install a private github repo of typescript models in multiple vercel projects. The docs mention "just use environment variables or .npmrc" but don't actually show a working example.
I do not want to use npm private packages. I want to install my own private github repo.
Forum posts like this highlight the issue and the lack of clarity: https://github.com/orgs/vercel/discussions/1395
The official docs: https://vercel.com/guides/using-private-dependencies-with-vercel
This syntax looks good in theory, but there's no clear way of actually keeping the access_token in vercel env vars
I have:
This will install locally but not during vercel builds.
1. Clarify the syntax, its unclear what should be my personal username and what should be the organizations profile name. The vercel docs mention <username> and <user> which is somewhat ambiguous.
2. Clarify how the vercel build steps access ${GITHUB_TOKEN}
3. Provide clarity on if .npmrc is needed when NOT using npm private modules. The docs seem to blur the lines.
4. Provide clarity on what github token permissions are needed.
5. Provide clarity on whether legacy or new personal access tokens are needed.
Thanks in advance!!!
I do not want to use npm private packages. I want to install my own private github repo.
Forum posts like this highlight the issue and the lack of clarity: https://github.com/orgs/vercel/discussions/1395
The official docs: https://vercel.com/guides/using-private-dependencies-with-vercel
This syntax looks good in theory, but there's no clear way of actually keeping the access_token in vercel env vars
"package-name": "git+https://<username>:<github_token>@github.com/<user>/<repo>.git"I have:
"myorg-types": "git+https://myusername:${GITHUB_TOKEN}@github.com/myorg/myorg-types.git",This will install locally but not during vercel builds.
1. Clarify the syntax, its unclear what should be my personal username and what should be the organizations profile name. The vercel docs mention <username> and <user> which is somewhat ambiguous.
2. Clarify how the vercel build steps access ${GITHUB_TOKEN}
3. Provide clarity on if .npmrc is needed when NOT using npm private modules. The docs seem to blur the lines.
4. Provide clarity on what github token permissions are needed.
read-only access is not helpful, there's MANY levels of read-only access. 5. Provide clarity on whether legacy or new personal access tokens are needed.
Thanks in advance!!!
13 Replies
CinnamonOP
Still unable to get this working.
My .npmrc file:
Error logs from vercel. Indicates permissions issue. Screenshot shows what's enabled on the github side
Second screenshot shows my vercel env vars with NPM_RC has specified by the vercel docs
My .npmrc file:
registry=https://registry.npmjs.org
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}Error logs from vercel. Indicates permissions issue. Screenshot shows what's enabled on the github side
ERROR Command failed with exit code 128: /usr/bin/git clone git@github.com:wideworldsai/wideworlds-types.git /vercel/.local/share/pnpm/store/v3/tmp/_tmp_115_74cc439c3294f18e46a19da6c7d35e8b
Cloning into '/vercel/.local/share/pnpm/store/v3/tmp/_tmp_115_74cc439c3294f18e46a19da6c7d35e8b'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
pnpm: Command failed with exit code 128: /usr/bin/git clone git@github.com:wideworldsai/wideworlds-types.git /vercel/.local/share/pnpm/store/v3/tmp/_tmp_115_74cc439c3294f18e46a19da6c7d35e8b
Cloning into '/vercel/.local/share/pnpm/store/v3/tmp/_tmp_115_74cc439c3294f18e46a19da6c7d35e8b'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at makeError (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:24966:17)
at handlePromise (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:25537:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async gitFetcher (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:114688:11)
at async fetcher (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:127322:16)
at async run (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:126787:23)
Error: Command "pnpm install" exited with 1Second screenshot shows my vercel env vars with NPM_RC has specified by the vercel docs
Toyger
NPM_RC should be
you need to replace NAMESPACE and PACKAGENAME based on this docs: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
registry=https://registry.npmjs.org
@NAMESPACE:registry=https://npm.pkg.github.com/PACKAGENAME
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}you need to replace NAMESPACE and PACKAGENAME based on this docs: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
@Toyger NPM_RC should be
yaml
registry=https://registry.npmjs.org
@NAMESPACE:registry=https://npm.pkg.github.com/PACKAGENAME
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
you need to replace NAMESPACE and PACKAGENAME based on this docs: <https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry>
CinnamonOP
I don't have a namespace or packagename. I'm not trying to host my NPM package on Github packages. I'm just trying to host a couple typescript files in a github repo that I need to sync across multiple projects.
not sure how this applies:
not sure how this applies:
You can configure npm to publish packages to GitHub Packages and to use packages stored on GitHub Packages as dependencies in an npm project.@Cinnamon I don't have a namespace or packagename. I'm not trying to host my NPM package on Github packages. I'm just trying to host a couple typescript files in a github repo that I need to sync across multiple projects.
not sure how this applies:
You can configure npm to publish packages to GitHub Packages and to use packages stored on GitHub Packages as dependencies in an npm project.
Toyger
npm_rc and github package is just easier way.
your
should be fine if you'll pass token in plain text, because about this
your
"myorg-types": "git+https://myusername:${GITHUB_TOKEN}@github.com/myorg/myorg-types.git",should be fine if you'll pass token in plain text, because about this
${GITHUB_TOKEN} I am not sure how it works on your localhost, afaik package.json don't have access to environment variables especially in such direct way.@Toyger npm_rc and github package is just easier way.
your
"myorg-types": "git+https://myusername:${GITHUB_TOKEN}@github.com/myorg/myorg-types.git",
should be fine if you'll pass token in plain text, because about this `${GITHUB_TOKEN}` I am not sure how it works on your localhost, afaik package.json don't have access to environment variables especially in such direct way.
CinnamonOP
I'm not supposed to put the token in plaintext, trying to figure out how to get vercel to see the env var, their docs are confusing and seem to be handling 4 different styles of installs without providing clear examples.
If I had to guess, I would say localhost install works because there's a ssh key in my path. I have a hunch that local install doesnt work with
${GITHUB_TOKEN} but its been bypassed with sshkey@Cinnamon I'm not supposed to put the token in plaintext, trying to figure out how to get vercel to see the env var, their docs are confusing and seem to be handling 4 different styles of installs without providing clear examples.
Toyger
most likely package.json can't process environment variables in any way, so it's easier to use way with git package registry, it shouldnt take a lot of time to add your repo to it.
the only way I can think of, you can do with package.json it's write some bash script that will run before build, and get env variable and replace it inside package.json right before module installation, so you don't need to put it into repository.
the only way I can think of, you can do with package.json it's write some bash script that will run before build, and get env variable and replace it inside package.json right before module installation, so you don't need to put it into repository.
@Toyger most likely package.json can't process environment variables in any way, so it's easier to use way with git package registry, it shouldnt take a lot of time to add your repo to it.
the only way I can think of, you can do with package.json it's write some bash script that will run before build, and get env variable and replace it inside package.json right before module installation, so you don't need to put it into repository.
CinnamonOP
Git package registry is a gitHUB thing or a gitLAB thing?
@Toyger github
CinnamonOP
Do you have an example of this working?
@Cinnamon Do you have an example of this working?
Toyger
you have everything here https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry
basically you make changes in package.json
and set everything related to authorization in .npm_rc
basically you make changes in package.json
and set everything related to authorization in .npm_rc
@Toyger you have everything here <https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry>
basically you make changes in package.json
and set everything related to authorization in .npm_rc
CinnamonOP
I don't have an npm package. I have a folder with 12 ts files in it. These files are in a github repo, I want to install this repo in a number of other repos as a dependency. I dont' want to use npm, I don't have an npm account, I do not have an npm package, I do not have a namespace, I'm not trying to
What am I missing here?
configure npm to publish packages to GitHub Packages and to use packages stored on GitHub Packages as dependencies in an npm project. as that webpage describes. What am I missing here?
@Cinnamon I don't have an npm package. I have a folder with 12 ts files in it. These files are in a github repo, I want to install this repo in a number of other repos as a dependency. I dont' want to use npm, I don't have an npm account, I do not have an npm package, I do not have a namespace, I'm not trying to `configure npm to publish packages to GitHub Packages and to use packages stored on GitHub Packages as dependencies in an npm project.` as that webpage describes.
What am I missing here?
Toyger
npm registry it is not an https://www.npmjs.com/ itself
it is npm.pkg.github.com which is github service https://github.com/features/packages
you don't need additional account, only your github account with your repo.
you need any registry only because you don't want to pass access token into package.json
in this case using github npm registry is easiest way
it is npm.pkg.github.com which is github service https://github.com/features/packages
you don't need additional account, only your github account with your repo.
you need any registry only because you don't want to pass access token into package.json
in this case using github npm registry is easiest way