NPM新手求助:Ubuntu 20.04环境下执行npm install触发EMISSINGARG错误
EMISSINGARG Error with npm install Hey there, let's break down what's going on here and fix this issue—this looks like a super common pitfall when you're new to NPM, so don't worry, we'll get it sorted!
First, Spot the Critical Mismatch
Take a close look at your error log and your npm version output:
- The error log shows you’re running Node v5.9.0 and NPM v3.9.5 when executing
npm install - But your
npm versioncommand confirms you have Node v14.12.0 and NPM v7.11.1 installed on your system
This version mismatch is almost certainly the root cause of your EMISSINGARG error. Your shell is calling an outdated, older version of NPM/Node instead of the newer one you think you're using.
Step-by-Step Fixes
1. Check Which Node/NPM Your Shell is Actually Using
Run these commands in your terminal to see the paths of the Node and NPM binaries being executed:
which node which npm
Compare these paths to where your Node v14.12.0 is installed (for example, if you used NVM, it might be in ~/.nvm/versions/node/v14.12.0/bin). If they point to a different location (like a system-installed version from Ubuntu's apt), that's the problem.
2. Fix Your PATH Environment Variable
You need to make sure the directory with your newer Node/NPM is prioritized in your system's PATH:
- Open your shell configuration file (like
~/.bashrc,~/.zshrc, or~/.profiledepending on which shell you use) in a text editor. - Add this line at the top (replace the path with your actual Node v14 installation directory):
export PATH="/path/to/your/node14/bin:$PATH" - Save the file, then restart your terminal or run
source ~/.bashrc(or the equivalent for your shell) to apply the changes.
3. Clean Up and Reinstall
Once you’ve confirmed you’re using the correct Node/NPM version:
- Delete the
node_modulesfolder andpackage-lock.jsonfile in your project:rm -rf node_modules package-lock.json - Clear the NPM cache to eliminate any corrupted data:
npm cache clean --force - Finally, re-run
npm install
Why This Happens
It’s really common to install Node.js multiple ways (e.g., first via Ubuntu’s apt repository, then using NVM for newer versions). Your system will default to the first version it finds in your PATH, so if the older system-installed version is listed before your newer one, it’ll get called instead.
内容的提问来源于stack exchange,提问作者Perimosh

