build: raise Node heap for production build

The production build renders thousands of modules and exceeds V8's
default heap ceiling, so `npm run build` fails with a JavaScript
heap out-of-memory error during "rendering chunks". Set
NODE_OPTIONS=--max-old-space-size=8192 on the Vite build step via
cross-env (kept portable for Windows), so a fresh clone builds
without any manual environment setup. Document the matching Docker
memory requirement in DOCKER.md, since the container build hits the
same limit when the Docker VM has too little RAM.
This commit is contained in:
Alberto Arena
2026-08-04 18:06:11 +02:00
parent ae9e052cf6
commit fe84e0d748
3 changed files with 30 additions and 1 deletions
+8
View File
@@ -103,6 +103,14 @@ RUN npm config set strict-ssl false && npm install
This is necessary in some build environments with certificate validation issues.
### Out of Memory During Build
The production build is memory-intensive (the app compiles thousands of modules). If `docker compose up` or `docker build` fails with an out-of-memory error such as `Reached heap limit` or `cannot allocate memory` during the `npm run build` step, increase the memory available to Docker:
- **Docker Desktop**: Settings, then Resources, then Memory. Set it to at least **6-8 GB** and apply.
The Dockerfile raises the Node heap (`NODE_OPTIONS=--max-old-space-size`) for the build. That heap size must fit inside the memory available to Docker, so raising the Docker memory limit is the fix when the build runs out of memory.
### Container Not Starting
Check the logs:
+20
View File
@@ -86,6 +86,7 @@
"@typescript-eslint/parser": "8.11.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "10.4.19",
"cross-env": "^7.0.3",
"esbuild": "^0.28.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "9.1.0",
@@ -8363,6 +8364,25 @@
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==",
"license": "MIT"
},
"node_modules/cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
"dev": true,
"license": "MIT",
"dependencies": {
"cross-spawn": "^7.0.1"
},
"bin": {
"cross-env": "src/bin/cross-env.js",
"cross-env-shell": "src/bin/cross-env-shell.js"
},
"engines": {
"node": ">=10.14",
"npm": ">=6",
"yarn": ">=1"
}
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+2 -1
View File
@@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "tsc && cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build",
"lint": "eslint -c .eslintrc.json ./src/**/**/*.{ts,tsx} --fix",
"preview": "vite preview"
},
@@ -88,6 +88,7 @@
"@typescript-eslint/parser": "8.11.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "10.4.19",
"cross-env": "^7.0.3",
"esbuild": "^0.28.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "9.1.0",