This error occurs when node-gyp can't find a C compiler on your system. Native npm modules require compilation, and this fails without build tools like gcc or clang installed.
The "not found: cc" error means node-gyp is trying to compile a native module but can't find a C compiler. The `cc` command is the standard C compiler that node-gyp expects in your PATH. Many npm packages include native code (C/C++) that must be compiled during installation. Packages like bcrypt, sqlite3, canvas, sharp, and node-sass all require compilation. node-gyp handles this compilation but needs: - A C/C++ compiler (gcc, clang, or MSVC) - Python 3.6+ - Make utility Without these tools, any package with native dependencies will fail to install.
Install the complete build toolchain:
sudo apt-get update
sudo apt-get install -y build-essential python3
# Verify installation
gcc --version
g++ --version
make --versionThe build-essential package includes gcc, g++, make, and other required tools.
Use the development tools group:
# RHEL/CentOS
sudo yum groupinstall "Development Tools"
sudo yum install python3
# Fedora
sudo dnf groupinstall "Development Tools"
sudo dnf install python3Install Xcode Command Line Tools:
xcode-select --installThis installs clang (Apple's C/C++ compiler), make, and other build tools. Follow the dialog prompts to complete installation.
Option 1 - Use windows-build-tools (run as Administrator):
npm install --global --production windows-build-toolsOption 2 - Install Visual Studio:
1. Download Visual Studio Community 2022
2. Select "Desktop development with C++" workload
3. Install Python from python.org or Microsoft Store
Configure npm if needed:
npm config set msvs_version 2022Add build tools to your Dockerfile:
For Debian-based images:
RUN apt-get update && apt-get install -y \
build-essential \
python3 \
&& rm -rf /var/lib/apt/lists/*For Alpine images:
RUN apk add --no-cache python3 make g++ build-baseAfter installing build tools:
# Clear npm cache
npm cache clean --force
# Retry installation
npm installPython version requirements: node-gyp requires Python 3.6+. Python 3.12+ requires node-gyp v10+. Set Python path explicitly if needed:
npm config set python /usr/bin/python3Upgrade node-gyp: If issues persist, upgrade node-gyp globally:
npm install -g node-gyp@latestPre-built binaries: Some packages offer pre-built binaries that skip compilation. Check the package documentation for alternatives like @node-rs/bcrypt instead of bcrypt.
CI/CD environments: Ensure your CI runner has build tools. For GitHub Actions, use an image with build tools or add a setup step. For Docker-based CI, include build tools in your image.
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
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