7 months ago
Hello Railway team,
I’m trying to deploy a modern React frontend using Vite 7.x on Railway, but the build fails due to Node.js version incompatibility: error vite@7.1.0: The engine "node" is incompatible with this module. Expected version "^20.19.0 || >=22.12.0". Got "20.18.1"
Details:
My repo contains a .nvmrc file set to 20.19.0 and "engines": { "node": ">=20.18.0 <21.0.0" } in package.json.
Railway only provides Node 20.18.1 (too old for Vite 7.x) or Node 22.11.0 (too early, not supported by Vite 7.x).
Vite 7.x (and other modern tools like Next.js, Astro, etc.) require at least Node 20.19.0 or Node 22.12.0 due to upstream ESM loader changes.
Could you please:
Add Node 20.19.0 (or newer) and/or Node 22.12.0+ to the available Node versions on Railway?
Or, let me know if there is a way to force Railway to use a custom Node version for my service?
Thank you for your help!
Ben
5 Replies
7 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
Railway
Hey there! We've found the following might help you get unblocked faster: - [🧵 Persistent SSL Error on Production Environment](https://station.railway.com/questions/persistent-ssl-error-on-production-envir-dd91e8b1) If you find the answer from one of these, please let us know by solving the thread!
7 months ago
nope
7 months ago
Hey,
You can add the NIXPACKS_NODE_VERSION environment variable to your project and set it to 21 it should work (https://nixpacks.com/docs/providers/node)
mateodemuynck
Hey,You can add the NIXPACKS_NODE_VERSION environment variable to your project and set it to 21 it should work (https://nixpacks.com/docs/providers/node)
7 months ago
didn't work but thanks, trying with a Dockerfile now, don't know if it's going to work
7 months ago
1. Railway supports Docker deployments so use dockerfile for just deployment
create a dockerfile and add this..then deploy to railway
FROM node:20.19.0-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
2. Use Railway's Nixpacks with custom Node version: You can try adding a nixpacks.toml file to specify the Node version:
create a toml file and add this
[phases.setup]
nixPkgs = ["nodejs-20_x"]