Adding to that, sometimes leftover junk in your node_modules or package-lock.json can cause memory issues, too. From my experience troubleshooting these builds, here’s a reliable cleanup routine:
- Delete your
node_modules
folder andpackage-lock.json
. - Run
npm install
fresh to get a clean slate. - Try
ionic serve
again with the Node heap size increased as before.
Also, make sure your local @ionic/app-scripts
version is up to date—some older versions had notorious memory leaks that triggered this exact “ineffective mark-compacts near heap limit allocation failed - JavaScript heap out of memory” error. These steps usually resolve it once and for all.