This EMISSINGARG error occurs when npm expects a package name argument but none was provided. Include the package name when using installation flags like --save or -g.
This error occurs when npm expects a package name argument but none was provided. The EMISSINGARG error code indicates a missing required argument #1, which is typically the package name. In most cases, developers have used `npm install` with a flag like `--save`, `-g`, or `--save-dev` but forgot to specify which package to install. However, this error can also be triggered by using an outdated version of npm (particularly versions 3.x), where npm's dependency resolution fails unexpectedly even on valid commands.
First, check that you're providing a package name when using installation flags:
# Correct - includes package name
npm install express
npm install express --save
npm install nodemon -g
npm install --save-dev jest
# Incorrect - missing package name (causes EMISSINGARG)
npm install --save
npm install -g
npm install --save-devIf you just want to install dependencies from package.json, use npm install without any flags.
Check your current npm version and upgrade if it's outdated:
# Check current version
npm --version
# Upgrade npm to the latest stable version
npm install -g npm@latest
# After upgrading, clear your shell's command cache
hash -r
# Verify the upgrade worked
npm --versionAim for npm 5.0 or higher. If you're on npm 3.x, upgrading is critical.
Instead of using system package managers, use nvm to install Node.js and npm cleanly:
# Install nvm (macOS/Linux)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Reload your shell configuration
source ~/.bashrc # or ~/.zshrc for macOS
# Install the latest LTS Node.js (includes modern npm)
nvm install --lts
# Verify installation
node --version && npm --versionIf the error persists after upgrading npm, try clearing the npm cache:
# Clear the npm cache
npm cache clean --force
# Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Reinstall all dependencies
npm install
# If installing a specific package, now try with correct syntax
npm install express --saveInvalid npm configuration can also cause this error. Check your .npmrc files:
# Check global npm config
cat ~/.npmrc
# Check project-level config
cat .npmrc
# Check npm configuration
npm config listIf you find deprecated or invalid settings, remove them or update them:
# Reset to defaults if needed
npm config set registry https://registry.npmjs.org/Create a test directory to isolate the issue:
# Create a temporary test directory
mkdir -p ~/npm-test
cd ~/npm-test
# Initialize a new npm project
npm init -y
# Try installing a common package
npm install lodash
# Check that package.json was updated
cat package.jsonIf these commands work, the issue was project-specific. If they still fail, you have a system-wide npm issue.
The EMISSINGARG error is particularly common in npm versions 3.5.x through 3.10.x due to a bug in npm's argument parser when resolving dependencies. While this was fixed in npm 3.10.8+, many CI/CD systems and older Docker containers still use these versions. If you control the Node.js installation (Docker, CI pipeline), explicitly specify a modern Node.js version (14.x, 16.x, 18.x, or later) which includes npm 6.x or higher. In Ubuntu/Debian systems, avoid apt install nodejs as it often installs very outdated versions; use the NodeSource repository or nvm instead.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm