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 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