Create react app ENOSPC issue on Linux

Node v8.12.0, create-react-app v2.1.5

Pavan
2 min readMar 1, 2019

Recently i created one react app using popular cli tool create-react-app and tried to run development server on Linux machine. I got a strange error and app failed to start.

ENOSPC error on executing npm start

From the error, it seems like the error is coming because of space crunch on machine. NodeJS throws ENOSPC (Error no space) when there is not enough space available to run the application. But df -h tells a different story. df -h return stats which clearly shows that the machine has ample amount of free space. So less space couldn’t be the reason behind the issue.

After searching on internet about the issue, we found a link one stack-overflow link which suggests to execute following command to fix the issue.

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

But why did we get the error? we just created a simple react app and how does this command solve the issue? After digging more, we come to know that linux machine put a limit on number of files inotify program can monitor. Above command increase the limit of number of files it can watch. This means that create-react-app is using inotify to monitor files and it is asking inotify to monitor files more than its limit.

But we just bootstrapped a simple app, how can it already cross the limit and who is using inotify? Error stack trace shows that npm module chokidar is throwing the error. On checking the dependent tab, its clear the babel and webpack both are using chokidar to monitor files. So probably, chokidar is using inotify to monitor project files.

By increasing number of file being watched by inotify limit will solve the issue. You need super user permission (sudo) to execute the above command. In case you don’t want to do development on linux machine. you just want to host the app then just create a build and run a simple server like http-server which will serve the app.

npm run buildnpm install http-serverhttp-server <path-to-build-folder> -a <hotname> -p <port-number>

I hope, this article would help understanding the cause and solution of ENOSPC issue with create-react-app.

--

--