Node.js: what is ENOSPC error and how to solve?

Solution 1:

Run the below command to avoid ENOSPC:

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

For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:

fs.inotify.max_user_watches=524288

Then execute:

sysctl --system

This will also persist across reboots. Technical Details Source

Solution 2:

ENOSPC means that there is no space on the drive.

Perhaps /tmp is full? You can configure npm to use a different temp folder by setting npm config set tmp /path/to/some/other/dir, or maybe delete everything out of the /tmp folder.

Source: npm 1.1.21 cannot write, ENOSPC in npm's repo in github.

Note I solved my problem in the way that described in above source. However, see Murali Krishna's answer, which is more comprehensive.