Gatsby Cloud supports working with private packages that are listed on the npm and yarn registries, as well as other custom registries.
Configuration
Gatsby Cloud will respect any .yarnrc
or .npmrc
files included in your repository. To avoid committing authorization token to your git repository you can use the NPM_TOKEN
environment variable.
Private packages hosted on the npm registry
The default registry on Gatsby Cloud is NPM (https://registry.npmjs.org/
).
For packages on the NPM registry, you only need to add NPM_TOKEN
as an environment variable and set it to your token.
NPM_TOKEN=YOUR_ACCESS_TOKEN
Private packages hosted on other registries
Private packages on other registries must be scoped (e.g. @myorg/mypackage
). The dependency in package.json
must be defined with it's scope, e.g.:
"@myorg/mypackage":"^1.0.0"
Additionally, you must include a .npmrc
file which:
- specifies the registry for the scoped package in the root directory of the gatsby project
- provides the authorization token to use for the registry
@myorg:registry=https://my.privateregistry.com/
//my.privateregistry.com/:_authToken=${NPM_TOKEN}
Then add the NPM_TOKEN
environment variable.
NPM_TOKEN=YOUR_ACCESS_TOKEN
Installing from a private git repo
You can install a private package directly from a private git repo using https and a token from Github.
- Go to https://github.com/settings/tokens
- Generate a new token with "repo" access
- Add the package to package.json
"mypackage": "git+https://token:x-oauth-basic@github.com/myorg/mypackage.git"
Gatsby Cloud does not support installation via SSH.
Comments
0 comments
Please sign in to leave a comment.