EFAULT occurs when npm or Node.js encounters an invalid memory address or filesystem issues during package operations. This typically indicates filesystem corruption, permission issues, or memory constraints.
The EFAULT (bad address) error is a low-level system call failure that occurs when npm or Node.js attempts an operation with an invalid memory address or encounters filesystem issues during package operations. This typically happens during critical npm operations like mkdir, copyfile, or other system calls that interact with the file system. The error indicates that the operating system rejected the request because the memory address provided was invalid or inaccessible, often pointing to underlying filesystem corruption, permission issues, or environment-specific problems rather than a bug in npm itself.
Start with a complete clean slate by removing corrupted cache and dependencies:
npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm installThe --force flag is required because npm refuses to clear the cache without it.
Verify that your filesystem has sufficient space and is healthy:
# Check available disk space
df -h
# Check for filesystem errors (Linux)
sudo fsck /dev/sdXY # replace with your partition
# On macOS, use Disk Utility or:
diskutil verifyVolume /Ensure the partition has at least 500MB free space. Check that /tmp directory permissions are correct: ls -ld /tmp should show drwxrwxrwt.
If running on a resource-constrained system, increase the memory available to Node.js:
# For npm 7+
NODE_OPTIONS="--max-old-space-size=4096" npm install
# For npm 6 and earlier
node --max-old-space-size=4096 /usr/local/bin/npm install
# For Docker, ensure adequate memory
docker run -m 4g your-image # allocate 4GB to containerEnsure npm can write to required directories:
# Check tmp directory permissions
ls -ld /tmp
# Should show: drwxrwxrwt
# If incorrect, fix permissions
sudo chmod 1777 /tmp
# Check npm cache directory permissions
chmod -R u+w ~/.npmSome versions of npm have known issues with file operations. Update to the latest stable versions:
# Check current versions
node --version
npm --version
# Update npm to latest
npm install -g npm@latest
# Update Node.js using nvm
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
nvm install 20
nvm use 20If the error persists, identify which package is causing the issue:
# Install packages individually to find the culprit
npm install package-name-1
npm install package-name-2
# Continue until error occurs
# Once identified, try a different version
npm install package-name@^1.5.0
# For cross-filesystem issues, verify the cache location
npm config get cache
# If it's on a different mount, consider changing it
npm config set cache /path/to/local/cacheThe EFAULT error at the system call level is particularly common in virtualized or containerized environments (Docker, WSL, Raspberry Pi) where system call support may be limited or memory is constrained. If running in Docker, ensure the container has at least 2GB of memory. For cross-volume operations, consider reconfiguring npm's cache directory to be on the same filesystem as your project. On Linux systems with SELinux or AppArmor enabled, verify that npm/node processes aren't being blocked by security policies. The error can also occur if the system's file descriptor limit is too lowโcheck with ulimit -n and increase if needed.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error