0

How to fix NodeJS/NPM ENOSPC error on Linux

Most of the newage javascript framework uses npm for their package management, testing etc. Be it angular, reactjs or any other js requires npm for many of it functionalities. One common issue that people face with npm command is ENOSPC error, especially when you execute the below command

Below is one such error I got while executing the above command. If you are also facing the same then read on, you can fix it pretty easily.

error_enospc

The error here as you can see (in CAPS) is ENOSPC, translates to no space on drive. If you get this error then basically it means you don’t have space on your disk to perform this operation. As a first step, you can check your disk space and make sure that you have enough space. You can also try to clear your /tmp file. After performing these actions still, the issue is not solved then it could be an issue with the inotify.

Before letting you know the fix, I though I will give you a small insight into inotify. You can always skip this and  go directly to the solution below.

The manual of inotify defines it as:

So basically inotify is an API within Linux kernel to monitor any filesystem events and report it to an application. All the linux distros have set a default limit for inotify. To know the default limit set in your distro, you can execute following command

In rare cases, this limit needs to be increased for some application to work and that could be the reason for the error we encountered with npm command.

Solution to fix ENOSPC Issue

To fix this ENOSPC issue, execute the following command (For Arch Linux, including arch based distros like Manjaro Linux, read further before executing below commands)

If you are running Arch Linux, skip the above commands and add the following entry into /etc/sysctl.d/99-sysctl.conf

Now execute

Now if you execute the npm test command, your tests should be executed properly without the ENOSPC error.

Swaroop Shankar V

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.