It can be complicated to have the same Node version between the local environment and the CI/CD. The latest Node.js version or the latest lts is released recently and if you want to upgrade to the Node version, usually you can forget to configure one environment. For that reason, it can be important to have only one source of truth to define the Node version, so you change in one place it impacts every environment.
Here we will use nvm and have the CI/CD example with Github Actions. Some other CI/CD solutions can exist elsewhere using a similar configuration and reproduce the common configuration.
First of all, you should configure a
.nvmrc file defining the version you want to use. This version will be used in your local environment. To use it, you can either make an
nvm use each time you go to the project's local directory or configure your bash to use it automatically.
Here is an example of a
.nvmrc file content:
Then, you can configure the Github Action so to use the same .nvmrc file.
steps: - name: Checkout uses: actions/checkout@v3 - name: Setup node env uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' cache: 'yarn'
Now, when you change the .nvmrc file, it changes the version used for your local environment, the Node environment for all your team, and the CI/CD running on Github.
If you're seeking solutions to a problem or need expert advice, I'm here to help! Don't hesitate to book a call with me for a consulting session. Let's discuss your situation and find the best solution together.
Collapsible sections in Markdown
Collapsible sections can help keep markdown organized and user-friendly. In this quick guide, we'll show how to create collapsible sections in a markdown.
Inject HTML content into an Astro component
While working on a project within the Astro framework, I encountered a scenario where I needed to fill HTML content within a script tag.
Read Package.json file from Node.JS module
When you write a program you may want to read the content of the package.json file like what is the current package version. Here is one very simple way to read the content of this file.
Introducing new blog on OAuth, OpenID Connect, and IAM Solutions
I'm excited to announce the launch of a new blog named CerberAuth, where I'll be exploring the world of OAuth, OpenID Connect, and IAM solutions for modern security.
MySQL Docker Image for Mac ARM M1
MySQL official Docker image is not available for Apple ARM-based M1 and M2 CPUs. But there is some options to use mysql image on Mac and more globally on ARMv8 microarchitecture.
How to deal with Docker Hub rate limit on AWS
Since 2020, DockerHub has been limited to only 200 container image pull requests per six hours. This article will help you to deal with this limitation on AWS.