I use GitHub Actions for all my CI, and one annoying thing I hit early on was having to keep my GitHub Actions Node version in sync with the Node version I use for development.
To solve that issue I've switched to using Volta for Node version management. It's nice because it can switch Node versions on the fly based on what's configured in package.json
, like this:
{
//...package.json
"volta": {
"node": "18.10.0"
}
}
Then in GitHub Actions I use these couple of steps to load my Volta version of Node:
# set NODE_VERSION to be Volta's current version
- run: echo NODE_VERSION=$(jq -r .volta.node package.json) >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
Top comments (0)