Build fails with "too many open files" error when using theme dependencies.
Bug Report or Feature Request (mark with an x)
- [x] bug report -> Did, could not find a suiting solution/answer.
- [ ] feature request
Versions.
@angular/cli: 1.0.0-rc.2
node: 6.10.0
os: linux x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 2.4.9
System:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
Repro steps.
- Create angular-cli project,
- Add a purchased theme, for example Metronic <- make sure it contains a lot of assets dependencies.
- Check what your system's open file limit is (mine is 1024 by default)
ulimit -a | grep 'open->open files (-n) 1024 - Run build command, mine is
ng build --target=development --environment=staging
The log given by the failure.
$ ng build --target=development --environment=staging
95% emittingfs.js:640
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EMFILE: too many open files, open '/home/forge/accp-products.caroga.nl/src/assets/metronic-bootstrap/assets/global/plugins/jquery.min.js'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.readFileSync (fs.js:508:33)
at Object.source (/home/forge/accp-products.caroga.nl/node_modules/@angular/cli/plugins/glob-copy-webpack-plugin.js:31:26)
at Compiler.writeOut (/home/forge/accp-products.caroga.nl/node_modules/webpack/lib/Compiler.js:322:26)
at /home/forge/accp-products.caroga.nl/node_modules/mkdirp/index.js:48:26
at FSReqWrap.oncomplete (fs.js:123:15)
Desired functionality.
- Successful build, without errors.
Mention any other details that might be useful.
ng servedoes compile and serves successfully.
ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: fc298eaefcd765c7d4fd
Time: 27248ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 156 kB {4} [initial] [rendered]
chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 1.08 MB {4} [initial] [rendered]
chunk {2} main.bundle.js, main.bundle.js.map (main) 60.9 kB {3} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.72 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
- Altering my system's open file limit does not work, I've quadrupled the size and still the error occurs. Make me think there might be something else at play.
$ ulimit -a | grep open
open files (-n) 4096
- The system's diskspace and available inodes are sufficient. No problem there:
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 996M 12K 996M 1% /dev
tmpfs 201M 428K 200M 1% /run
/dev/xvda1 20G 6.9G 12G 37% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 1001M 4.0K 1001M 1% /run/shm
none 100M 0 100M 0% /run/user
$ df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 249K 388 249K 1% /dev
tmpfs 251K 335 250K 1% /run
/dev/xvda1 1.3M 720K 561K 57% /
none 251K 2 251K 1% /sys/fs/cgroup
none 251K 1 251K 1% /run/lock
none 251K 2 251K 1% /run/shm
none 251K 2 251K 1% /run/user
- Both project and global Angular-cli versions match each other.
- A list of the plugins:

- Maybe even the most important one: I have NOT included all of these plugins in my config. They are just sitting there. I've only included the following inside my
styles.scss:
/* BEGIN GLOBAL MANDATORY STYLES */
@import "assets/metronic-bootstrap/assets/global/plugins/font-awesome/css/font-awesome.min.css";
@import "assets/metronic-bootstrap/assets/global/plugins/simple-line-icons/simple-line-icons.min.css";
@import "assets/metronic-bootstrap/assets/global/plugins/bootstrap/css/bootstrap.min.css";
@import "assets/metronic-bootstrap/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css";
/* BEGIN THEME GLOBAL STYLES */
@import "assets/metronic-bootstrap/assets/global/css/components.min.css";
@import "assets/metronic-bootstrap/assets/global/css/plugins.min.css";
/* BEGIN THEME LAYOUT STYLES */
@import "assets/metronic-bootstrap/assets/layouts/layout2/css/layout.min.css";
@import "assets/metronic-bootstrap/assets/layouts/layout2/css/themes/blue.min.css";
@import "assets/metronic-bootstrap/assets/layouts/layout2/css/custom.min.css";
This is weird as it fails on assets/metronic-bootstrap/assets/global/plugins/jquery.min.js while I've not included this yet. I also don't see anything inside my .angular-cli.json that might suggest such inclusion:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"version": "1.0.0-beta.32.3",
"name": "product-builder"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"staging": "environments/environment.staging.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"files": "src/**/*.ts",
"project": "src/tsconfig.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}
- Excluding the folder inside
tsconfig.jsonproves no success either:
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
],
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"exclude": [
"./assets/metronic-bootstrap"
]
}
}
Your config is setup to copy everything within the assets directory to the build output.
@clydin Understood, but not really workable? Would the underlying copy mechanism not use some sort of graceful fs move method? As I would be needing these dependencies in time and don't see another way of copying in this myself (cause, yeah: pipelines are for that).
Can you advice on this?
We mostly just add these files to the Webpack watched assets. Then webpack takes care of reading and watching it: https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/plugins/glob-copy-webpack-plugin.ts#L47-L52.
There might be a hard limit somewhere that's not only the system. This needs some investigation.
How many files do you have total in assets/ right now?
But you are copying an awful lot of files... not to say you shouldn't, nor that we shouldn't support it. Just saying that it's not optimal.
A better way of doing it is to actually import the styles and scripts you need specifically into the scripts and styles array instead of adding everything there to be copied wholesale. Cause yeah, pipelines are also for that.
I have this issue as well. For my application I'm depending on the cldr-data npm package. From an API, I'm receiving the configuration for grid columns. In the tool it's possible to specify any locale for a column, so I need all the locale information in the package.
In my .angular-cli.json file I have added the package to the assets configuration so that I can load the needed files dynamically:
"assets": [
"assets",
"favicon.ico",
"../node_modules/cldr-data/main"
]
This package contains so many locales that I'm getting the Error: EMFILE: too many open files error as well when running ng build. When I'm running ng serve everything works as expected.
My setup:
@angular/cli: 1.0.0 node: 7.7.4 os: win32 x64 @angular/common: 4.0.1 @angular/compiler: 4.0.1 @angular/core: 4.0.1 @angular/forms: 4.0.1 @angular/http: 4.0.1 @angular/platform-browser: 4.0.1 @angular/platform-browser-dynamic: 4.0.1 @angular/router: 4.0.1 @angular/cli: 1.0.0 @angular/compiler-cli: 4.0.1
@Caroga, @glenstaes
Hello I fix it by change config in .angular-cli.json at
"assets": [
"assets",
"favicon.ico"
],
to
"assets": [
"favicon.ico"
],
after build completed I make a junction link to dist
ln -s /project/src/assets /project/dist/assets
(or you can copy folder to dist path)
@filipesilva I'm running into this issue as well. My project contains ArcGIS for Javascript API sourcecodes which must be deployed locally. The folder contains tons of js files.
Angular CLI throws following error during ng build --prod. ng serve works ok.
An error occured during the build:
Error: EMFILE: too many open files, open 'C:\Development\Intens.Osks.Gis\Intens.Osks.Gis.Website\wwwroot\assets\arcgis-js-api\4.6\esri\portal\Bookmark.js'
EMFILE: too many open files, open 'C:\Development\Intens.Osks.Gis\Intens.Osks.Gis.Website\wwwroot\assets\arcgis-js-api\4.6\esri\portal\Bookmark.js'
Error: EMFILE: too many open files, open 'C:\Development\Intens.Osks.Gis\Intens.Osks.Gis.Website\wwwroot\assets\arcgis-js-api\4.6\esri\portal\Bookmark.js'
Yes, I can copy them over manually but I would prefer to keep all the necessary assets in the build. Hope this will get solved soon 👍
Can you reproduce this issue with the latest CLI? If this is still valid, would you provide a minimal demo where we can reproduce the problem?
Hi, I tried to replicate this with the latest version of the CLI (7.1.1). I added 4,500 files and was unable to replicate this.
If the problem persists, please open a new issue following our submission guidelines.
A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.