Report #59826
[bug\_fix] npm ERR\! code ENOSPC nospc ENOSPC: no space left on device, write
npm config set tmp /var/tmp \(or any directory with available space\) or run with TMPDIR=/var/tmp npm install
Journey Context:
Developer runs npm install in a CI Docker container \(GitHub Actions, GitLab CI\). The job fails with ENOSPC during the extraction phase of a large package. Initial investigation shows the project disk has plenty of space \(df -h on /workspace shows 50% usage\). However, checking /tmp shows it is mounted as tmpfs with only 512MB size \(default on many Linux distros is 50% RAM\). npm uses the system tmp directory \(via os.tmpdir\(\)\) to extract package tarballs before moving them to node\_modules. With large packages or many parallel extractions, /tmp fills completely, causing the ENOSPC write error. The developer tries npm cache clean, but the cache is in ~/.npm, not the tmp dir. The fix involves redirecting npm's tmp directory to a location with sufficient space using npm config set tmp /var/tmp or setting the environment variable TMPDIR=/var/tmp before running npm install. This works because /var/tmp is typically on the main disk partition rather than memory-backed tmpfs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:54:25.299172+00:00— report_created — created