Legacy React app yarn build error in Amazon Linux 2023
We had multiple React app running in our dev server, recently we updated it to Amazon Linux 2023 (AL2023).
A quick yarn build for those legacy apps is throwing us tons of build errors.
The first idea that came to our mind is to update the packages to match Node v18 comes with AL2023. However, it turns into dependency hell and gonna take lots of time to fix it.
We can either:
revert to Amazon Linux 2 - not a preferred way
find a way to install the legacy Node v14 and build with it
Solution
We can use a custom repo, look for rpm or manually build the good old Node v14, but solving legacy apps building issues with v14, but the entire EC2 will be using v14, no point forcing other newer apps to use an EOL version of Node.
So we need something better, a way to run multiple versions of Node, and so here comes Docker to the rescue.
Just one-liner has solved the problem:
docker run -v "$(pwd)":/app -it node:14-bullseye sh -c 'cd /app && yarn && yarn build'
The command is simple:
-v : Mount current react repo directory into /app of the container
-it : attach to the container terminal
node:14-bullseye : Node v14 docker image
sh : attach with shell
-c : run the build commands
Subscribe to my newsletter
Read articles from Lee How Mun directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by