How to fix npm ERR! code EMISSINGARG npm ERR! Missing required argument: package name in npm
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.
Quick fix
Fixes EMISSINGARG
# 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-dev- Verify your npm command syntax
- Check and upgrade your npm version
- Use Node Version Manager (nvm) for clean updates
- Clean npm cache if upgrading doesn't work
# Correct - includes package namenpm install expressnpm install express --savenpm install nodemon -gnpm install --save-dev jest# Incorrect - missing package name (causes EMISSINGARG)npm install --savenpm install -gnpm install --save-devnpm ERR! code EMISSINGARGnpm ERR! Missing required argument: package name
What this error means
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.
Typical symptoms
- npm command fails with 'ERR! code EMISSINGARG' and 'Missing required argument: package name'
- Error appears when running commands like 'npm install --save' or 'npm install -g' without a package name
- Commands that previously worked suddenly fail with EMISSINGARG in CI/CD environments
- npm install commands hang or fail with TypeError about missing argument #1
- Global package installation commands (npm install -g) fail unexpectedly
Common causes
- Forgot to specify a package name when using installation flags (--save, -g, --save-dev, --save-optional)
- Using an outdated version of npm (versions 3.5.x to 3.10.x are known to have this issue)
- Corrupted or outdated Node.js version installed via system package manager rather than nvm
- npm cache is corrupted or npm registry metadata is invalid for a dependency
- Using npm 6.x or earlier in a CI/CD pipeline where npm wasn't properly initialized
- Custom npm configuration (in .npmrc) has invalid syntax or deprecated settings
How to fix "npm ERR! code EMISSINGARG npm ERR! Missing required argument: package name"
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.
Advanced notes
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.
Frequently asked questions
- What does "EMISSINGARG" mean?
- 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.
- How do I fix "EMISSINGARG"?
- 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.
- What causes "EMISSINGARG"?
- Forgot to specify a package name when using installation flags (--save, -g, --save-dev, --save-optional) Using an outdated version of npm (versions 3.5.x to 3.10.x are known to have this issue) Corrupted or outdated Node.js version installed via system package manager rather than nvm
- Is the "EMISSINGARG" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: npm CLI documentation(Official Docs)
- ๐ฌSO: npm missing argument errors(Stack Overflow)
- ๐GitHub: npm issues(GitHub)