nuxt: too many open files on build
Environment
- Operating System:
Windows 11
- Node Version:
v16.15.0
- Nuxt Version:
3.0.0
- Nitro Version:
1.0.0
- Package Manager:
yarn@1.22.19
- Builder:
vite
- User Config:
runtimeConfig
,modules
,routeRules
,css
,build
,vite
,i18n
- Runtime Modules:
@nuxtjs/i18n@8.0.0-beta.7
,@pinia/nuxt@0.4.6
,@nuxt/image-edge@1.0.0-27840416.dc1ed65
,@vueuse/nuxt@9.9.0
,nuxt-lodash@2.4.1
,bootstrap-vue-3/nuxt
- Build Modules:
-
Reproduction
N/a
Describe the bug
When trying to build the project this error occurs
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 15 (3 by maintainers)
@camhart @danielroe I wanted to share the resolution we found for the
EMFILE: too many open files
error we encountered while building the project. The issue appeared only on the Windows machine.The issue was caused by using extremely broad patterns in
tailwind.config.js
file, specifically:./*.html
These patterns were scanning a large number of files, including those in thenode_modules
folder, causing the file limit to be exceeded. To resolve this issue, we refined the patterns intailwind.config.js
file to target only the necessary files and folders in the project. This change significantly reduced the number of files being processed, and the EMFILE error disappeared. Another positive effect was, that build speed was significantly increased. 🚀 I hope this solution helps others who may be facing similar issues!💪https://tailwindcss.com/docs/content-configuration#configuring-source-paths
I also hit this issue recently, and found something of a workaround.
I’m using docker, so the solution was to add this option to the
docker build
command when building:--ulimit nofile=5000:5000
. If you’re using WSL, you will need to manually increase yournofile
limit.Explanation
The
EMFILE: too many open files
error comes from the kernel when you try to open too many files at once as an individual user. This normally isn’t an issue if the default limit is very high or unlimited, but containerized environments and some distros will limit the default to 1024 for non-privileged containers. This includes WSL/Ubuntu.See the following stackoverflow answers for more details.
https://stackoverflow.com/a/21070580/2351110 (linux and WSL) https://stackoverflow.com/a/43265189/2351110 (docker)
@danielroe No not really, it was fixed 3 releases after this issue