This error occurs when node-gyp can't find the Node.js development headers needed to compile native modules. Usually caused by missing or corrupted header files.
The ENOENT error for `common.gypi` means node-gyp can't find the Node.js development headers. These headers contain the C/C++ definitions needed to compile native modules that interface with Node.js internals. node-gyp looks for these headers in several locations: - Downloaded in ~/.node-gyp/ - System-installed in /usr/include/node/ - Bundled with Node.js installation This error typically occurs when: - Headers weren't downloaded for your Node.js version - Headers are corrupted or incomplete - Using a Node.js version installed without headers - The nodedir configuration points to wrong location
Tell node-gyp to download headers for your Node.js version:
node-gyp installThis downloads headers to ~/.node-gyp/ (or %USERPROFILE%\.node-gyp on Windows).
If headers are corrupted, remove and re-download:
# Remove cached headers
rm -rf ~/.node-gyp
# Re-download
node-gyp install
# Retry npm install
npm installIf using system Node.js, install the dev package:
Debian/Ubuntu:
sudo apt-get install nodejs-devRHEL/CentOS/Fedora:
sudo yum install nodejs-devel
# or
sudo dnf install nodejs-develPoint node-gyp to the correct headers location:
# Find your Node.js version
node --version
# Set nodedir (adjust path as needed)
npm config set nodedir ~/.node-gyp/$(node --version | cut -c 2-)
# Or for a single install
npm install --nodedir=/path/to/node/headersOlder node-gyp versions may have issues finding headers:
npm install -g node-gyp@latestnvm users: When switching Node.js versions with nvm, headers for the new version may not exist. Run node-gyp install after switching versions.
Offline environments: If you can't download headers, you can manually copy them from another machine. Place them in ~/.node-gyp/VERSION/.
Header version matching: The headers must match your exact Node.js version. node-gyp uses your current Node.js version to determine which headers to download.
System vs nvm Node.js: If you have both system Node.js and nvm, ensure you're using consistent versions. Mixing can cause header mismatches:
which node # Check which Node.js is being used
node --versionnpm 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