The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.18.0"

Hi, This seems like a common error but I’m still not finding a solution. My site works on my local machine but fails to build on Netlify. Im a bit confused on how to solve this issue
my current node version is v19.0.1

site address - agitated-ride-5dcf8a

4:15:05 PM: ---------------------------------------------------------------------
DEPRECATION NOTICE: Builds using the Xenial build image will fail after November 15th, 2022.

The build image for this site uses Ubuntu 16.04 Xenial Xerus, which is no longer supported.
All Netlify builds using the Xenial build image will begin failing in the week of November 15th, 2022.

To avoid service disruption, please select a newer build image at the following link:
https://app.netlify.com/sites/agitated-ride-5dcf8a/settings/deploys#build-image-selection

For more details, visit the build image migration guide:
https://answers.netlify.com/t/please-read-end-of-support-for-xenial-build-image-everything-you-need-to-know/68239
---------------------------------------------------------------------
4:15:07 PM: build-image version: e3a92d323f65dadd9483189ed53791424b7b61a7 (xenial)
4:15:07 PM: build-image tag: v3.15.1
4:15:07 PM: buildbot version: b8818322cd07df39ed42700557962e5781043dd7
4:15:07 PM: Building without cache
4:15:07 PM: Starting to prepare the repo for build
4:15:07 PM: No cached dependencies found. Cloning fresh repo
4:15:07 PM: git clone https://github.com/Slavi-Svec/portfolio-website-v4
4:15:08 PM: Preparing Git Reference refs/heads/master
4:15:08 PM: Parsing package.json dependencies
4:15:09 PM: Starting build script
4:15:09 PM: Installing dependencies
4:15:09 PM: Python version set to 2.7
4:15:10 PM: v12.18.0 is already installed.
4:15:10 PM: Now using node v12.18.0 (npm v6.14.4)
4:15:10 PM: Started restoring cached build plugins
4:15:10 PM: Finished restoring cached build plugins
4:15:10 PM: Attempting ruby version 2.7.1, read from environment
4:15:11 PM: Required ruby-2.7.1 is not installed - installing.
4:15:11 PM: Searching for binary rubies, this might take some time.
4:15:11 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/16.04/x86_64/ruby-2.7.1.tar.bz2
4:15:11 PM: Checking requirements for ubuntu.
4:15:11 PM: Requirements installation successful.
4:15:11 PM: ruby-2.7.1 - #configure
4:15:11 PM: ruby-2.7.1 - #download
4:15:11 PM: ruby-2.7.1 - #validate archive
4:15:14 PM: ruby-2.7.1 - #extract
4:15:16 PM: ruby-2.7.1 - #validate binary
4:15:16 PM: ruby-2.7.1 - #setup
4:15:17 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1@global
4:15:17 PM: ruby-2.7.1 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
4:15:17 PM: ruby-2.7.1 - #generating global wrappers........
4:15:17 PM: ruby-2.7.1 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.7.1
4:15:17 PM: ruby-2.7.1 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
4:15:17 PM: ruby-2.7.1 - #generating default wrappers........
4:15:17 PM: Using /opt/buildhome/.rvm/gems/ruby-2.7.1
4:15:18 PM: Using ruby version 2.7.1
4:15:18 PM: Using PHP version 5.6
4:15:18 PM: Started restoring cached yarn cache
4:15:18 PM: Finished restoring cached yarn cache
4:15:18 PM: Found yarn version (1.22.10) that doesn't match expected (1.22.4)
up to date in 0.021s
4:15:19 PM: Installing yarn at version 1.22.4
4:15:19 PM: Installing Yarn!
4:15:19 PM: > Downloading tarball...
4:15:19 PM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.16y1nhTAT6
4:15:19 PM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
4:15:19 PM:                                  Dload  Upload   Total   Spent    Left  Speed
4:15:19 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:15:19 PM: 100    79  100    79    0     0    374      0 --:--:-- --:--:-- --:--:--   376
4:15:19 PM: 100    93  100    93    0     0    206      0 --:--:-- --:--:-- --:--:--   206
4:15:19 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:15:19 PM:  30 1215k   30  368k    0     0   493k      0  0:00:02 --:--:--  0:00:02  493k
4:15:19 PM: 100 1215k  100 1215k    0     0  1584k      0 --:--:-- --:--:-- --:--:-- 39.4M
4:15:19 PM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.16y1nhTAT6.asc
4:15:19 PM: 100    83  100    83    0     0   1874      0 --:--:-- --:--:-- --:--:--  1874
4:15:19 PM: 100    97  100    97    0     0   1280      0 --:--:-- --:--:-- --:--:--  1280
4:15:19 PM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
4:15:19 PM: 100  1028  100  1028    0     0   9354      0 --:--:-- --:--:-- --:--:--  9354
4:15:19 PM: > Verifying integrity...
4:15:19 PM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
4:15:19 PM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
4:15:19 PM: gpg: WARNING: This key is not certified with a trusted signature!
4:15:19 PM: gpg:          There is no indication that the signature belongs to the owner.
4:15:19 PM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
4:15:19 PM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
4:15:19 PM: > GPG signature looks good
4:15:19 PM: > Extracting to ~/.yarn...
4:15:19 PM: > Adding to $PATH...
4:15:20 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
4:15:20 PM: No yarn workspaces detected
4:15:20 PM: Started restoring cached node modules
4:15:20 PM: Finished restoring cached node modules
4:15:20 PM: Installing NPM modules using Yarn version 1.22.4
4:15:20 PM: yarn install v1.22.4
4:15:20 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
4:15:20 PM: [1/4] Resolving packages...
4:15:21 PM: [2/4] Fetching packages...
4:15:23 PM: warning file-loader@2.0.0: Invalid bin field for "file-loader".
4:15:23 PM: warning mini-css-extract-plugin@0.4.3: Invalid bin field for "mini-css-extract-plugin".
4:15:23 PM: warning url-loader@1.1.1: Invalid bin field for "url-loader".
4:15:23 PM: warning terser-webpack-plugin@1.1.0: Invalid bin field for "terser-webpack-plugin".
4:15:33 PM: error expect@29.3.1: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.18.0"
4:15:33 PM: error Found incompatible module.
4:15:33 PM: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
4:15:33 PM: Error during Yarn install
4:15:33 PM: Creating deploy upload records
4:15:33 PM: Build was terminated: Build script returned non-zero exit code: 1
4:15:33 PM: Failing build: Failed to build site
4:15:33 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
4:15:34 PM: Finished processing build request in 26.966267556s`Preformatted text`

After trying a few things this finally worked, I changed the version in netlify [Environment variables]

Thanks for sharing that solution @python-pete !