The EPACK error occurs when npm cannot create a tarball (.tgz) file during npm pack or npm publish. This is typically caused by permission issues, corrupted cache, or invalid package.json configuration.
This error indicates npm failed to create the compressed archive (tarball) that contains your package. The tarball is the standard format for distributing npm packages—it's what gets uploaded to the registry during publish or created locally with npm pack. The failure can occur at various stages: reading source files, compressing content, or writing the output file. The underlying cause is often permission-related or involves corrupted npm state.
Start with the most common fix—clearing corrupted cache:
# Clear npm cache completely
npm cache clean --force
# Verify cache integrity
npm cache verify
# Try packing again
npm packVerify you have write access to the current directory:
# Check directory permissions
ls -la
# Fix ownership of npm directories (Linux/macOS)
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
# Ensure directories are executable
chmod u+x -R ~/.npmImportant: Never use sudo npm as it creates permission conflicts.
Avoid system-wide permission issues by using a local npm directory:
# Create local npm directory
mkdir -p ~/.npm-global
# Configure npm to use it
npm config set prefix '~/.npm-global'
# Add to PATH in ~/.bashrc or ~/.zshrc
export PATH=~/.npm-global/bin:$PATH
source ~/.bashrcEnsure your package.json is valid:
# Check for syntax errors
npm ls 2>&1 | head -20
# Validate JSON format
cat package.json | python -m json.toolRequired fields for publishing:
{
"name": "my-package",
"version": "1.0.0"
}Ensure sufficient disk space for tarball creation:
# Linux/macOS
df -h
# Windows
wmic logicaldisk get name,size,freespaceFree up space if needed:
npm cache clean --force
rm -rf node_modulesOn Windows, check the npm directory exists:
# Check npm directory
echo %APPDATA%\npm
# Create if missing
mkdir %APPDATA%\npm
# Fix npm prefix
npm config set prefix "%APPDATA%\npm"If distributing tarballs created on Windows to Linux/macOS systems, ensure directories have execute permissions. Windows doesn't have the same permission model, so tarballs may have incorrect flags.
For private registry authentication issues, run npm install -g @scope/package first to cache credentials, then npm pack will work.
Consider using NVM (Node Version Manager) to avoid system-wide permission issues entirely.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error