Skip to content

Commit fe84e0d

Browse files
committed
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.
1 parent ae9e052 commit fe84e0d

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

DOCKER.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ RUN npm config set strict-ssl false && npm install
103103

104104
This is necessary in some build environments with certificate validation issues.
105105

106+
### Out of Memory During Build
107+
108+
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:
109+
110+
- **Docker Desktop**: Settings, then Resources, then Memory. Set it to at least **6-8 GB** and apply.
111+
112+
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.
113+
106114
### Container Not Starting
107115

108116
Check the logs:

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc && cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build",
99
"lint": "eslint -c .eslintrc.json ./src/**/**/*.{ts,tsx} --fix",
1010
"preview": "vite preview"
1111
},
@@ -88,6 +88,7 @@
8888
"@typescript-eslint/parser": "8.11.0",
8989
"@vitejs/plugin-react": "^4.2.1",
9090
"autoprefixer": "10.4.19",
91+
"cross-env": "^7.0.3",
9192
"esbuild": "^0.28.0",
9293
"eslint": "^8.57.0",
9394
"eslint-config-prettier": "9.1.0",

0 commit comments

Comments
 (0)