How to fix npm ERR! canceled in npm

npmINTERMEDIATEMEDIUMUpdated Dec 5, 2025· 155 views

The 'npm ERR! canceled' error occurs when npm abruptly terminates an operation, typically due to user interruption, network timeout, cache corruption, or missing packages in non-interactive environments.

Quick fix

Fixes npm ERR! canceled

npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm install
  1. Clear npm cache and reinstall from scratch
  2. Increase npm timeout settings
  3. Check your network and proxy settings
  4. Use npm ci instead of npm install (for CI/CD)
npm — error
npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm install
npm ERR! canceled

What this error means

The "npm ERR! canceled" error occurs when npm abruptly terminates a package installation or operation. This error is often vague—npm doesn't always clearly explain why the cancellation happened—but it typically indicates that a process was interrupted, failed to proceed, or encountered a condition that forced npm to stop. Unlike more specific errors (like network timeouts or missing packages), "canceled" is a catch-all that requires investigating the debug log and context to understand the root cause. The error commonly appears during npm install, npm ci, or npx commands. The error can stem from user intervention (pressing Ctrl+C), network problems, cache corruption, or missing packages in non-interactive environments.

Typical symptoms

  • npm install hangs and then shows 'npm ERR! canceled' without further explanation
  • CI/CD pipeline fails with 'npm ERR! canceled' during GitHub Actions or GitLab CI builds
  • npx command cancels with 'npm ERR! canceled due to missing packages and no YES option'
  • Install completes partially then aborts, leaving node_modules in an incomplete state
  • Debug log exists but provides minimal detail about what triggered the cancellation

Common causes

  1. User pressed Ctrl+C or otherwise interrupted npm while installation was in progress
  2. Network timeout or connectivity dropped during package download
  3. npm cache is corrupted or contains invalid checksums, causing verification to fail
  4. npx running with --no-install flag but required packages aren't available locally (non-interactive env)
  5. Child process (like a build script) was killed or failed, causing npm to abort
  6. Insufficient disk space, permission issues, or system resource exhaustion

How to fix "npm ERR! canceled"

1Clear npm cache and reinstall from scratch

Corrupted cache is a common cause. Remove the cache and node_modules folder:

bash
npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm install

This forces npm to re-download all packages and verify checksums. You can also verify cache integrity before cleaning:

bash
npm cache verify
2Increase npm timeout settings

Network timeouts commonly trigger canceled errors. Increase the timeout values:

bash
npm config set fetch-timeout 1800000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 120000
npm config set fetch-retry-maxtimeout 600000

Or edit ~/.npmrc directly:

bash
fetch-timeout = 1800000
fetch-retries = 5
fetch-retry-mintimeout = 120000
fetch-retry-maxtimeout = 600000

These values give npm up to 30 minutes to fetch packages with 5 retries.

3Check your network and proxy settings

Verify your proxy configuration:

bash
npm config get proxy
npm config get https-proxy

If these are set incorrectly, reset them:

bash
npm config delete proxy
npm config delete https-proxy

If you need a proxy, configure it correctly:

bash
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy https://proxy.example.com:8080

Temporarily disable VPN to verify it's not the cause.

4Use npm ci instead of npm install (for CI/CD)

In CI environments, use npm ci (clean install) instead of npm install:

bash
npm ci

npm ci uses exact versions from package-lock.json and fails more explicitly if there are issues.

For npx with missing packages, add --yes to auto-confirm:

bash
npx --yes some-package@latest
5Check debug log for specific error details

When npm prints 'npm ERR! canceled', it references a debug log. Find it:

bash
A complete log of this run can be found in:
  /home/user/.npm/_logs/2024-01-15T10_30_45_123Z-debug-0.log

Inspect the log file for more context:

bash
cat ~/.npm/_logs/2024-01-15T10_30_45_123Z-debug-0.log

Look for error keywords like 'ETIMEDOUT', 'ERR_SOCKET_TIMEOUT', 'permission denied', or 'signal SIGINT'.

6Verify disk space and system resources

Insufficient disk space can trigger cancellations mid-install:

bash
df -h

Ensure you have at least 1-2 GB free. If disk is low, clear unnecessary files:

bash
# macOS
rm -rf ~/Library/Caches/npm

# Linux
rm -rf ~/.npm

Also verify your system has enough memory. Large projects need adequate RAM.

Advanced notes

Signal Handling & Interrupts: When you press Ctrl+C during npm install, npm receives SIGINT. Older versions of npm didn't handle this cleanly. Modern npm (v7+) respects the signal but may take time to gracefully shut down. A second Ctrl+C sends SIGKILL, which terminates immediately.

It's safe to interrupt npm install—npm v3+ automatically repairs node_modules if interrupted, so re-running npm install will fix any partial state.

CI/CD Specifics: In GitHub Actions, npx --no-install combined with a missing package triggers "npx canceled due to missing packages and no YES option". The solution is either: (a) pre-install the package with npm install, (b) use npx --yes, or (c) install globally.

Network Resilience: Transient network hiccups can cancel an install. npm has built-in retry logic, but the default retry counts may be conservative. Increasing fetch-retries to 5+ and fetch-retry-maxtimeout to 10+ minutes helps with unreliable networks.

Frequently asked questions

What does "npm ERR! canceled" mean?
The "npm ERR! canceled" error occurs when npm abruptly terminates a package installation or operation. This error is often vague—npm doesn't always clearly explain why the cancellation happened—but it typically indicates that a process was interrupted, failed to proceed, or encountered a condition that forced npm to stop.
How do I fix "npm ERR! canceled"?
The 'npm ERR! canceled' error occurs when npm abruptly terminates an operation, typically due to user interruption, network timeout, cache corruption, or missing packages in non-interactive environments.
What causes "npm ERR! canceled"?
User pressed Ctrl+C or otherwise interrupted npm while installation was in progress Network timeout or connectivity dropped during package download npm cache is corrupted or contains invalid checksums, causing verification to fail
Is the "npm ERR! canceled" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading