#Build error: EMFILE: too many open files

1 messages · Page 1 of 1 (latest)

left widget
#

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?

drifting prismBOT
#

Hi @left widget. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error EMFILE: too many open files typically occurs when the system has reached its limit for the maximum number of open file descriptors. It seems like your Next.js application is trying to open more files than your system limit allows.

Based on the information from the extracts, there are a few potential solutions you could try:

  1. Modularize Imports: One user mentioned that they were loading the entire lodash library files, which exceeded the maximum number of modules allowed by Vercel. They fixed this issue by using Next.js's new feature, Modularize Imports (https://www.linkedin.com/posts/vercel_nextjs-131-modularize-imports-activity-7016055204072611840-GxGQ). This feature allows you to import only the parts of a library that you need, reducing the number of files that need to be opened.

  2. Check Your Dependencies: Another user found that the issue was caused by a specific dependency (phosphor-icons/react in their case). They solved the problem by adding a setting to next.config as suggested in a comment on a related issue in the phosphor-icons/react repository. You could check if any of your dependencies are known to cause this issue and see if there are any recommended solutions.

  3. Remove Deprecated Packages: If you're using deprecated packages like next-transpile-modules, consider removing them. One user mentioned that removing this package fixed the issue for them, as transpiling modules is now natively supported by Next.js (https://github.com/martpie/next-transpile-modules/releases/tag/the-end).

#

Unfortunately, without more specific information about your project setup and dependencies, it's hard to provide a more precise solution. If none of the above solutions work, you might want to consider reaching out to the Next.js community or opening an issue on the Next.js GitHub repository for more help.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: