Canvas Deployment Issue on Railway + Node.js 22

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!

Solved$10 Bounty

1 Replies

irazvan2745
PRO

23 days ago

build your own docker image or use a .nvmrc


realdonalfred
HOBBY

23 days 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.


irazvan2745
PRO

23 days ago

also, use railpack, it should use the latest one


I did what you say, and It works, thanks


irazvan2745
PRO

22 days ago

can you submit my message as the answer so i get my bounty


Sure, how it works?


irazvan2745
PRO

22 days ago

click on central station thread


irazvan2745
PRO

22 days ago

and mark my message as the answer


Status changed to Solved brody 22 days ago


Status changed to Solved noahd 22 days ago


22 days ago

sorted ;)


22 days ago

!s


Loading...