JavaScript FAQ
You can use any version of Node.js with Release.
For Docker containers:
For Docker containers, you can pull in a source image and version with a tag like
FROM node:16
at the top of your Dockerfile
. Internally, we use nvm and recommend you do too. Take a look at this example of adding nvm to an Alpine image.For static build images:
For static build images, we use nvm, which will use whatever version of Node.js you have in a
.nvmrc
file. You can specify a global version at the top of your build directory and override it with different versions further down the directory structure if you need to. Read the nvm docs for more information, or take a look at this Stack Overflow answer.Yes, but using npm libraries might require some additional work on your part. This guide to Docker and private modules from the npm documentation provides all the technical details. In brief:
- 1.Add a
.nprmrc
file to your code repository with contents that look something like//registry.npmjs.org/:_authToken=${NPM_TOKEN}
. Do not fill in your token here, use the variable that will be substituted later (this file is safe to check into your code version system). - 2.Add a build argument to your
Dockerfile
, preferably somewhere near the top (add a comment so you can remember why you put it there). The line looks likeARG NPM_TOKEN
. - 3.Add a copy command so the file is copied into your Docker container. The copy command should be placed below the build argument but above the
npm install
command. The line looks likeCOPY .npmrc .npmrc
. - 4.Push your changes to GitHub or Bitbucket on a branch.
- 5.Be sure to generate a token or use an existing one that is READ-ONLY and can be revoked safely without affecting your other pipelines. Anyone who is an owner of your Release account can see and change these build arguments.
- 6.
Once you've completed these steps, your build should use the npm token you supplied to pull private libraries. If it works, merge your changes to the default or main development branch.
To install GitHub Packages, you'll need to follow the same steps as outlined for npm repositories above. Ensure that your token has privileges for
['read:packages']
Your
.npmrc
file should look similar to://npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@myorg:registry=https://npm.pkg.github.com/
For static service deployments, you can use environment variables to add your token. Remember to add
secret: true
.While app-level build arguments will work for static service deployments, these are usually reserved for Docker images.
To use Yarn, follow the instructions for npm above, then add a
.yarnrc
file for the private repository. Take a look at this Gist for more information.