7 months ago
I'm deploying a backend on Railway (Express + Prisma + PostgreSQL) that generates PDF reports with charts using canvas@2.11.2 and chartjs-node-canvas. Deployment fails because Railway uses Node.js 22, and canvas has no prebuilt binaries for that version. I tried forcing Node.js 20 via .nixpacks.toml, railway.toml, and package.json, but Railway ignores all and sticks to Node 22.
I also tried using a Dockerfile with node:20-alpine, but Railway ignores it and defaults to Nixpacks. I attempted source compilation by adding all required aptPkgs, but it fails due to missing Python and other libs.
Questions:
- Has anyone successfully forced Node.js 20 on Railway with Nixpacks?
- Is there an alternative to canvas that works with Node.js 22?
- Can Railway be configured to use Docker instead of Nixpacks?
- Any way to enable chart generation in this setup? For now, I disabled chart generation and the backend runs fine, but I need to restore full functionality. Any help appreciated!
10 Replies
7 months ago
Yes, you can build your custom own docker image or use a .nvmrc. Another alternative it's upgrading your canvas version to 3.2.x.
7 months ago
I did what you say, and It works, thanks
7 months ago
Sure, how it works?
Status changed to Solved noahd • 7 months ago
7 months ago
sorted ;)
7 months ago
!s

