Building with lots of assets (EMFILE error)


#1

Hi All,

A little help on building with lots of assets.

ionic info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v10.1.0
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.3.1 Build version 9E501
Environment Variables:
ANDROID_HOME : /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx
Misc:
backend : pro

Below is the error:
ionic “cordova” “build” “–release” “–emulator” “android” “–buildConfig” “/var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/__bitrise-cordova-build-config__348550309/build.json” “–prod”
Running app-scripts build: --prod --platform android --target cordova
[22:24:50] build prod started …
(node:5317) ExperimentalWarning: The fs.promises API is experimental
[22:24:51] clean started …
[22:24:51] clean finished in 1 ms
[22:24:51] copy started …
[22:25:04] deeplinks started …
[22:25:04] deeplinks finished in 181 ms
[22:25:04] ngc started …
[ERROR] Error: EMFILE: too many open files, open ‘/usr/local/lib/node_modules/ionic/node_modules/lodash/isEqual.js’
at Object.fs.openSync (fs.js:559:3)
at Object.fs.readFileSync (fs.js:465:33)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:688:20)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Promise.all.Promise.resolve.then (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-utils/lib/config.js:90:94)
Error: tsconfig: Cannot read file ‘/Users/vagrant/git/tsconfig.json’: EMFILE: too many open files, open ‘/Users/vagrant/git/tsconfig.json’.
at new BuildError (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at Object.getTsConfig (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/transpile.js:313:15)
at Object. (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:56:44)
at step (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at /Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:7:71
at new Promise ()
at __awaiter (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:3:12)
at Object.runAot (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:51:12)
at runNgc (/Users/vagrant/git/node_modules/@ionic/app-scripts/dist/ngc.js:28:27)
[22:25:11] copy finished in 20.32 s

I just added 15k files in assets and it stops building. Without the 15k files in asset, the build is working.
I have already check ulimit and it is set to unlimited.

I want to use graceful-fs but I do not know how or where the ionic cordova build command works.

Any input is appreciated.

Thank you and regards.