I am trying to create an app that displays a large amount of data. While compiling the app locally, I have experienced the “JavaScript heap out of memory” error that so many other have seen.
I develop on both Mac and Windows machines. On my Mac, I fixed this issue by adding:
export NODE_OPTIONS=--max_old_space_size=16384
to my .zshrc.
On windows I modified several files in node_modules.bin to look like this: (The files I modified all started with ng.)
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" --max_old_space_size=16384 "$basedir/../@angular/cli/bin/ng" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" --max_old_space_size=16384 "$basedir/../@angular/cli/bin/ng" $args
$ret=$LASTEXITCODE
}
(Yes, 16384 is 16 GB of RAM. My app isn’t nearly that big. I set it there because I have the RAM to spare and don’t want to deal with this again.)
When I try to use AppFlow to build, predictably, I get this same error. Does anyone have a solution for this? Can I set environmental variables on the VM that is doing the build? Do I modify package.json scripts to include --max_old_space_size=16384?
I have been told in the past by tech support not to include node_modules in my git repository or it won’t build so I think the fix I used for Windows is not possible here. (Willing to be wrong.)
I have seen in some older postings that I should upgrade app-scripts. I don’t have that in my package.json. I have also seen people talk about editing ionic.cmd. I don’t have that file either. I assume that advice is for older versions of ionic?
The research I have done shows that a lot of people have this problem building locally with Ionic, but I don’t see anyone discussing the problem with AppFlow. I hope that’s because the problem is trivial to fix and my inexperience is the main issue.
Thanks for reading this. Any help would be appreciated.
My package.json file for reference:
{
“name”: “redacted”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “https://ionicframework.com/”,
“scripts”: {
“ng”: “ng”,
“start”: “ng serve”,
“build”: “ng build”,
“test”: “ng test”,
“lint”: “ng lint”,
“e2e”: “ng e2e”
},
“private”: true,
“dependencies”: {
“@angular/cdk”: “^9.2.4”,
“@angular/common”: “~9.1.6”,
“@angular/core”: “~9.1.6”,
“@angular/forms”: “~9.1.6”,
“@angular/material”: “^9.2.4”,
“@angular/platform-browser”: “~9.1.6”,
“@angular/platform-browser-dynamic”: “~9.1.6”,
“@angular/router”: “~9.1.6”,
“@capacitor/android”: “^2.1.0”,
“@capacitor/core”: “2.1.0”,
“@capacitor/ios”: “^2.1.0”,
“@ionic-native/core”: “^5.0.7”,
“@ionic-native/splash-screen”: “^5.0.0”,
“@ionic-native/status-bar”: “^5.0.0”,
“@ionic/angular”: “^5.0.0”,
“rxjs”: “~6.5.1”,
“tslib”: “^1.10.0”,
“zone.js”: “~0.10.2”
},
“devDependencies”: {
“@angular-devkit/build-angular”: “~0.901.5”,
“@angular/cli”: “~9.1.5”,
“@angular/compiler”: “~9.1.6”,
“@angular/compiler-cli”: “~9.1.6”,
“@angular/language-service”: “~9.1.6”,
“@capacitor/cli”: “2.1.0”,
“@ionic/angular-toolkit”: “^2.1.1”,
“@types/jasmine”: “~3.5.0”,
“@types/jasminewd2”: “~2.0.3”,
“@types/node”: “^12.11.1”,
“codelyzer”: “^5.1.2”,
“jasmine-core”: “~3.5.0”,
“jasmine-spec-reporter”: “~4.2.1”,
“karma”: “~5.0.0”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage-istanbul-reporter”: “~2.1.0”,
“karma-jasmine”: “~3.0.1”,
“karma-jasmine-html-reporter”: “^1.4.2”,
“protractor”: “~5.4.3”,
“ts-node”: “~8.3.0”,
“tslint”: “~6.1.0”,
“typescript”: “~3.8.3”
},
“description”: “An Ionic project”
}
1 post - 1 participant