How to fix npm ERR! gyp ERR! stack Error: not found: cc in npm
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.
Quick fix
Fixes npm ERR! gyp ERR! stack Error: not found: cc
sudo apt-get update
sudo apt-get install -y build-essential python3
# Verify installation
gcc --version
g++ --version
make --version- Install build tools on Linux (Debian/Ubuntu)
- Install build tools on Linux (RHEL/CentOS/Fedora)
- Install build tools on macOS
- Install build tools on Windows
sudo apt-get updatesudo apt-get install -y build-essential python3# Verify installationgcc --versiong++ --versionmake --versionnpm ERR! gyp ERR! stack Error: not found: cc
What this error means
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.
Typical symptoms
- npm install fails with 'gyp ERR! not found: cc'
- Error occurs when installing packages with native modules
- Packages like bcrypt, sqlite3, node-sass fail to install
- Works on some machines but not others
Common causes
- C/C++ compiler not installed on system
- Build tools (gcc, g++, make) not in PATH
- Fresh system without development tools
- Minimal Docker image without build essentials
- Python not installed or wrong version
How to fix "npm ERR! gyp ERR! stack Error: not found: cc"
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 installAdvanced notes
Python 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.
Frequently asked questions
- What does "npm ERR! gyp ERR! stack Error: not found: cc" mean?
- 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.
- How do I fix "npm ERR! gyp ERR! stack Error: not found: cc"?
- 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.
- What causes "npm ERR! gyp ERR! stack Error: not found: cc"?
- C/C++ compiler not installed on system Build tools (gcc, g++, make) not in PATH Fresh system without development tools
- Is the "npm ERR! gyp ERR! stack Error: not found: cc" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐GitHub: node-gyp(GitHub)
- ๐Docs: node-gyp guide(Official Docs)
- ๐ฌSO: node-gyp build issues(Stack Overflow)