How to fix npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, terminating in npm
The npm SIGINT error occurs when a process is interrupted by pressing Ctrl+C or receiving an interrupt signal. This is usually expected behavior but can leave npm operations in an inconsistent state if interrupted at the wrong time.
Quick fix
Fixes npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, terminating
# If you just pressed Ctrl+C, the error is expected
# Simply try running the command again
npm install
# Check if a process manager is killing npm
ps aux | grep npm- Verify the interruption was intentional
- Clean and repair node_modules after interrupted install
- Run Node scripts directly instead of via npm
- Implement graceful shutdown handling in your code
# If you just pressed Ctrl+C, the error is expected# Simply try running the command againnpm install# Check if a process manager is killing npmps aux | grep npmnpm ERR! code SIGINTnpm ERR! errno SIGINTnpm ERR! Received SIGINT, terminating
What this error means
The npm SIGINT error occurs when a process is terminated by a SIGINT (interrupt) signal, typically when you press Ctrl+C in your terminal. This is a standard Unix signal mechanism for gracefully terminating processes. When you interrupt an npm command (like npm install, npm start, or npm run), npm catches the SIGINT signal and reports it as an error. In most cases, this error is not fatal and simply means the process was stopped mid-execution. However, it's important to understand what caused the interruption and whether your environment was left in a corrupted state, especially if SIGINT was received during npm install. The error message itself doesn't indicate a problem with your code—it's npm's way of acknowledging that a running process was interrupted by a signal rather than completing normally.
Typical symptoms
- Terminal displays npm ERR! code SIGINT after pressing Ctrl+C
- npm install or build process stops abruptly
- Partially installed node_modules folder with incomplete dependencies
- npm run dev or other scripts stop unexpectedly without completing
- Error occurs even though the Ctrl+C command was intentional
Common causes
- Intentional process interruption (Ctrl+C)—user presses Ctrl+C while npm command is running
- npm install interrupted mid-dependency fetch before all dependencies are downloaded
- Terminal session ends or connection drops (SSH connection lost, terminal window closed)
- Timeout in CI/CD pipelines—build process takes too long and system sends SIGINT
- npm run script interrupted before completion by Ctrl+C or external signal
- Signal forwarding issues—npm doesn't properly handle or forward SIGINT to child processes
How to fix "npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, terminating"
First, confirm whether you intentionally pressed Ctrl+C or if the process was interrupted by something else:
# If you just pressed Ctrl+C, the error is expected
# Simply try running the command again
npm install
# Check if a process manager is killing npm
ps aux | grep npmIf you deliberately stopped an npm command, this is expected behavior and the error can be safely ignored.
If you interrupted npm install mid-execution, your node_modules may be in an inconsistent state:
# Remove corrupted dependencies and lock file
rm -rf node_modules package-lock.json
# Reinstall all dependencies
npm installFor yarn users:
rm -rf node_modules yarn.lock
yarn installnpm doesn't always properly handle signals like SIGINT. Run Node directly for better signal handling:
# Instead of: npm start
# Run directly without npm:
node server.js
# For development with auto-reload:
npx nodemon server.jsThis gives your process direct control over signal handling.
Add signal handlers to manage SIGINT gracefully:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200);
res.end('Hello World\n');
});
function gracefulShutdown() {
console.log('Received SIGINT, shutting down gracefully...');
server.close(() => {
console.log('Server closed. Exiting.');
process.exit(0);
});
// Force shutdown after 5 seconds if graceful shutdown fails
setTimeout(() => {
console.error('Could not close connections in time');
process.exit(1);
}, 5000);
}
process.on('SIGINT', gracefulShutdown);
process.on('SIGTERM', gracefulShutdown);
server.listen(3000);When running via npm, SIGINT can sometimes trigger twice. Use process.once() instead:
// Instead of process.on() which allows multiple calls
process.once('SIGINT', () => {
console.log('SIGINT received once, shutting down');
// Cleanup code here
process.exit(0);
});This prevents your handler from executing multiple times on rapid interrupts.
In Docker and CI/CD systems, SIGINT errors are often due to container termination:
FROM node:18
WORKDIR /app
COPY . .
RUN npm install
# Run node directly (not through npm) to handle signals properly
CMD ["node", "server.js"]For GitHub Actions, ensure long-running processes have proper timeouts:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm run buildAdvanced notes
Signal Types: SIGINT is sent when Ctrl+C is pressed (exit code 130), while SIGTERM is a more graceful termination signal used by process managers and container orchestration systems. SIGKILL (exit code 137) is forceful and cannot be caught by applications.
npm Architecture Issue: npm acts as a parent process to your Node.js script, which can interfere with signal propagation. Some npm versions (9.6.7 to 9.8.1) had regressions in signal handling. Running Node directly bypasses this problem entirely.
Multiple SIGINT Calls: If your SIGINT handler is called multiple times, check if the server is still listening before attempting cleanup: if (server.listening) { server.close(...) }
Lock File Corruption: If npm install was severely interrupted, you might also need to clear the npm cache: npm cache clean --force before reinstalling.
Frequently asked questions
- What does "npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, t" mean?
- The npm SIGINT error occurs when a process is terminated by a SIGINT (interrupt) signal, typically when you press Ctrl+C in your terminal. This is a standard Unix signal mechanism for gracefully terminating processes. When you interrupt an npm command (like npm install, npm start, or npm run), npm catches the SIGINT signal and reports it as an error.
- How do I fix "npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, t"?
- The npm SIGINT error occurs when a process is interrupted by pressing Ctrl+C or receiving an interrupt signal. This is usually expected behavior but can leave npm operations in an inconsistent state if interrupted at the wrong time.
- What causes "npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, t"?
- Intentional process interruption (Ctrl+C)—user presses Ctrl+C while npm command is running npm install interrupted mid-dependency fetch before all dependencies are downloaded Terminal session ends or connection drops (SSH connection lost, terminal window closed)
- Is the "npm ERR! code SIGINT npm ERR! errno SIGINT npm ERR! Received SIGINT, t" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm docs: npm scripts(Official Docs)
- 🐙GitHub: npm SIGINT issues(GitHub)
- 💬Stack Overflow: SIGINT npm(Stack Overflow)