Anyone with a Vite PWA project deployed on Heroku? I get memory quota issues on build

I’ve build a Node.js web app on heroku. It runs perfectly but I noticed that I’m seeing console.log output in the console. So I figure I need to have heroku build a production version when I deploy (I tried building a production version locally then uploading and I still see console.log messages).

So I added to my Procfile npm run build which my project package.json scripts looks like this:

"scripts": {
    "start": "vite",
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview",
    "test.e2e": "cypress run",
    "test.unit": "vitest",
    "lint": "eslint"

When I deployed I got this error:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I added this to my config: NODE_OPTIONS="--max_old_space_size=2560"

and when I deploy again I get these errors:

2023-08-21T11:22:16.254912+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2023-08-21T11:22:36.729004+00:00 heroku[web.1]: Process running mem=791M(154.6%)
2023-08-21T11:22:36.730711+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2023-08-21T11:22:44.637382+00:00 app[web.1]: rendering chunks...
2023-08-21T11:22:57.219656+00:00 heroku[web.1]: Process running mem=1259M(245.9%)
2023-08-21T11:22:57.220692+00:00 heroku[web.1]: Error R15 (Memory quota vastly exceeded)
2023-08-21T11:22:57.221662+00:00 heroku[web.1]: Stopping process with SIGKILL

How do I resolve this? I am using the Basic Dyno. Is that not enough to build this project or am I missing something? Has anyone else built a vite project on Heroku that doesn’t display the console.log output?

I don’t know about Heroku, but on GitHub Actions, I needed 4GB of RAM to build successfully.

1 Like