How to fix npm ERR! gyp ERR! stack Error: not found: cc in npm

npmBEGINNERHIGHUpdated Dec 5, 2025ยท 132 views

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
  1. Install build tools on Linux (Debian/Ubuntu)
  2. Install build tools on Linux (RHEL/CentOS/Fedora)
  3. Install build tools on macOS
  4. Install build tools on Windows
npm โ€” error
sudo apt-get update
sudo apt-get install -y build-essential python3
# Verify installation
gcc --version
g++ --version
make --version
npm 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

  1. C/C++ compiler not installed on system
  2. Build tools (gcc, g++, make) not in PATH
  3. Fresh system without development tools
  4. Minimal Docker image without build essentials
  5. Python not installed or wrong version

How to fix "npm ERR! gyp ERR! stack Error: not found: cc"

1Install build tools on Linux (Debian/Ubuntu)

Install the complete build toolchain:

bash
sudo apt-get update
sudo apt-get install -y build-essential python3

# Verify installation
gcc --version
g++ --version
make --version

The build-essential package includes gcc, g++, make, and other required tools.

2Install build tools on Linux (RHEL/CentOS/Fedora)

Use the development tools group:

bash
# RHEL/CentOS
sudo yum groupinstall "Development Tools"
sudo yum install python3

# Fedora
sudo dnf groupinstall "Development Tools"
sudo dnf install python3
3Install build tools on macOS

Install Xcode Command Line Tools:

bash
xcode-select --install

This installs clang (Apple's C/C++ compiler), make, and other build tools. Follow the dialog prompts to complete installation.

4Install build tools on Windows

Option 1 - Use windows-build-tools (run as Administrator):

powershell
npm install --global --production windows-build-tools

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

bash
npm config set msvs_version 2022
5Install build tools in Docker

Add build tools to your Dockerfile:

For Debian-based images:

dockerfile
RUN apt-get update && apt-get install -y \
    build-essential \
    python3 \
    && rm -rf /var/lib/apt/lists/*

For Alpine images:

dockerfile
RUN apk add --no-cache python3 make g++ build-base
6Retry npm install

After installing build tools:

bash
# Clear npm cache
npm cache clean --force

# Retry installation
npm install

Advanced notes

Python version requirements: node-gyp requires Python 3.6+. Python 3.12+ requires node-gyp v10+. Set Python path explicitly if needed:

bash
npm config set python /usr/bin/python3

Upgrade node-gyp: If issues persist, upgrade node-gyp globally:

bash
npm install -g node-gyp@latest

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