7 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](https://github.com//.git)
I should clarify that Railway has access to all of the organization's repositories.
2 Replies
7 months ago
N/A
7 months ago
Yes, here's how to get it working:
Generate a GitHub Personal Access Token (PAT)
Go to https://github.com/settings/tokens → Generate a token with:reposcope (for private repos)read:packagesif you're using GitHub Packages
In Railway → Variables, add:
GH_TOKEN=ghp_yourlongtokenhereIn 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" }Use
.npmrc(optional but safer)
You can also create a.npmrcfile 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
.npmrcexists andGH_TOKENis set in Railway.