Will I be able to install a private package?

10 months ago

I have two repositories in my GitHub organization. One is a package/module/library, and the other is a full-fledged project that uses this library.

Question: Can Railway install a dependency in the form of this private package? Using git+https://github.com//.git

I should clarify that Railway has access to all of the organization's repositories.

$10 Bounty

2 Replies

10 months ago

N/A


10 months ago

Yes, here's how to get it working:

  1. Generate a GitHub Personal Access Token (PAT) Go to https://github.com/settings/tokens → Generate a token with:
    • repo scope (for private repos)
    • read:packages if you're using GitHub Packages
  2. In Railway → Variables, add:
GH_TOKEN=ghp_yourlongtokenhere  
  1. In your package.json, add the private package like this:
"dependencies": {  
  "my-private-lib": "git+https://$GH_TOKEN@github.com/my-org/my-private-lib.git"  
}  
  1. Use .npmrc (optional but safer) You can also create a .npmrc file in your root with:
//github.com/:_authToken=${GH_TOKEN}  

Then in package.json:

"dependencies": {  
  "my-private-lib": "git+https://github.com/my-org/my-private-lib.git"  
 }  

Remember:

  • Do not hardcode the token in package.json; always use Railway env variables or .npmrc.
  • If using Yarn, same idea applies, just make sure .npmrc exists and GH_TOKEN is set in Railway.

Welcome!

Sign in to your Railway account to join the conversation.

Loading...