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

10 Replies

irazvan2745
FREE

10 months ago

build your own docker image or use a .nvmrc


realdonalfred
PRO

10 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.


irazvan2745
FREE

10 months ago

also, use railpack, it should use the latest one


I did what you say, and It works, thanks


irazvan2745
FREE

10 months ago

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


Sure, how it works?


irazvan2745
FREE

10 months ago

click on central station thread


irazvan2745
FREE

10 months ago

and mark my message as the answer


Status changed to Solved noahd 10 months ago


10 months ago

sorted ;)


10 months ago

!s


Welcome!

Sign in to your Railway account to join the conversation.

Loading...