EMFILE: too many open files
Unanswered
Cape lion posted this in #help-forum
Cape lionOP
I upgraded next.js to 14.10 and some other packages, my app is not building, when i try to build i got this
$ env-cmd -f ./.env.dev next build
â–² Next.js 14.1.0
- Environments: .env.local
Skipping linting
✓ Checking validity of types
Creating an optimized production build ...
✓ Compiled successfully
✓ Collecting page data
✓ Generating static pages (176/176)
And then this appears:
[Error: EMFILE: too many open files, open 'path\node_modules\next\dist\server\base-server.js'] {
errno: -4066,
code: 'EMFILE',
syscall: 'open',
path: 'path\node_modules\next\dist\server\base-server.js'
}
I use windows and have no idea how to fix it, i tried to removed some pages and then it works, but it doesn't matter which page, can anyone help me with this?
$ env-cmd -f ./.env.dev next build
â–² Next.js 14.1.0
- Environments: .env.local
Skipping linting
✓ Checking validity of types
Creating an optimized production build ...
✓ Compiled successfully
✓ Collecting page data
✓ Generating static pages (176/176)
And then this appears:
[Error: EMFILE: too many open files, open 'path\node_modules\next\dist\server\base-server.js'] {
errno: -4066,
code: 'EMFILE',
syscall: 'open',
path: 'path\node_modules\next\dist\server\base-server.js'
}
I use windows and have no idea how to fix it, i tried to removed some pages and then it works, but it doesn't matter which page, can anyone help me with this?
24 Replies
@Cape lion try running this then build
ulimit -n 4096Cape lionOP
but can you tell me why should i change limit of open files before build?
is it caused by some code/package error or just the size of app is too big ?
It means that the maximum number of file descriptors has been reached
its a common issue in windows I think
Cape lionOP
is the issue also common in docker? or should be fine?
And i think windows doesn't handle ulimit -n 4096, AI says it's avaiable only in Unix-like systems
Cape lionOP
any ideas @Anay-208 ?
oh my bad
it should work
Cape lionOP
But there should be a way to build app in windows, it is very weird, it's so hard to debug the problem
Cape lionOP
@Anay-208 i lost a hope to resolve the bug, there is like no way to debug it, i hope anyone faced this and found a solution..
Cape lionOP
but how can i use graceful-fs if i don't use fs function in my app
@Cape lion but how can i use graceful-fs if i don't use fs function in my app
try this in next.config.[js,mjs]:
module.exports = {
webpack: (config, { isServer }) => {
if (!isServer) {
// We're in the browser build, so we can safely replace 'fs' with an empty module
config.resolve.fallback.fs = false;
} else {
// We're in the server build, replace 'fs' with 'graceful-fs'
config.resolve.alias.fs = require.resolve('graceful-fs');
}
return config;
},
};Cape lionOP
i'm trying, thanks @Anay-208
Not working :/
Wsl is your option