vite build error: out of memory
Problem
NOTE - PLEASE READ This issue has affected a number of people. Please do not comment with comments along the lines of "I'm also hitting this", but add a thumbs up to the issue instead. We know this is an important issue and "me too" comments will only drown out the comments from people attempting to resolve this issue and will be hidden. Please note however that Vite is a community driven project and a fix may need to come from the community For tips on working around the issue, please see https://rollupjs.org/guide/en/#error-javascript-heap-out-of-memory Describe the bug vite build error: out of memory. Reproduction https://github.com/Axeldeblen/realworld-big-build Possible improvements Reduce magic string memory usage when building source maps: https://github.com/Rich-Harris/magic-string/pull/161#issuecomment-607480189 Logs (Optional if provided reproduction) <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 00007FF69790ABBD] Security context: 0x01e6a86408d1 1: decode(aka decode) [000002AD02F874D1] [E:\vite-template\node_modules_rollup@2.40.0@rollup\dist\shared\rollup.js:~133] pc=0000039464A55451 2: decodedSourcemap(aka decodedSourcemap) [000002AD02F8A979] [E:\vite-template\node_modules_rollup@2.40.0@rollup\dist\shared\roll... FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF696CD180F napi_wrap+119407 2: 00007FF696C787E6 v8::internal::OrderedH
Error Output
error: out of memory.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: vite build error: out of memory
Update It worked when I allocated a whopping 16GB of RAM for Vite's initialization cycle. As a temporary workaround, you can use the following commands. If it still fails, just increase the size. Temporary workaround a. Using command line arguments ~~~ node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js ~~~ b. Using environment variables ~~~ export NODE_OPTIONS=--max-old-space-s
Trust Score
6 verifications
- 1
Update It worked when I allocated a whopping 16GB of RAM for Vite's initializati
Update It worked when I allocated a whopping 16GB of RAM for Vite's initialization cycle.
- 2
As a temporary workaround, you can use the following commands. If it still fails
As a temporary workaround, you can use the following commands. If it still fails, just increase the size.
- 3
a. Using command line arguments
a. Using command line arguments
- 4
Step 4
node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js ~~~
Validation
Resolved in vitejs/vite GitHub issue #2433. Community reactions: 29 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep