How to fix npm ERR! code ECANCELLED npm ERR! npm init cancelled in npm
The ECANCELLED error occurs when npm init is interrupted, typically by pressing Ctrl+C during the interactive prompts. This is a user-initiated cancellation, not a system error.
Quick fix
Fixes npm ERR! code ECANCELLED npm ERR! npm init cancelled
npm init -y
# or
npm init --yes- Use non-interactive mode
- Complete the interactive prompts
- Configure npm defaults
- Fix frozen prompts
npm init -y# ornpm init --yesnpm ERR! code ECANCELLEDnpm ERR! npm init cancelled
What this error means
ECANCELLED indicates the npm init process was intentionally stopped before completion. This happens when you press Ctrl+C (or Ctrl+Break on Windows) during the interactive questionnaire. npm init normally asks several questions (package name, version, description, etc.) and creates package.json based on your answers. Pressing Ctrl+C sends an interrupt signal that cancels the process. This is not a bug or system error—it's npm acknowledging that you chose to stop the initialization. No package.json is created when cancelled.
Typical symptoms
- Error appears after pressing Ctrl+C
- npm init prompts stop responding
- No package.json created
- Terminal shows cancelled message
Common causes
- User pressed Ctrl+C during prompts
- Terminal input stream interrupted
- Prompts appeared frozen (user cancelled)
- Input piped incorrectly to npm init
How to fix "npm ERR! code ECANCELLED npm ERR! npm init cancelled"
Skip all prompts with -y flag:
npm init -y
# or
npm init --yesThis creates package.json with defaults:
- name: current directory name
- version: 1.0.0
- main: index.js
If you want to fill in details, answer all prompts:
npm init
# Answer each prompt:
package name: (my-project)
version: (1.0.0)
description: My awesome project
entry point: (index.js)
test command:
git repository:
keywords:
author: Your Name
license: (ISC) MIT
Is this ok? (yes) yesDon't press Ctrl+C until you see "Is this ok?"
Set defaults so npm init -y uses your info:
npm config set init-author-name "Your Name"
npm config set init-author-email "you@example.com"
npm config set init-license "MIT"
npm config set init-version "0.1.0"Now npm init -y uses these values.
If prompts freeze (known Node.js 8.1.0 bug):
# Check Node version
node --version
# If 8.1.0, upgrade:
nvm install 20
nvm use 20
# Then retry
npm initIf cancellation left partial files:
# Check if package.json exists
ls package.json
# If incomplete, remove and retry
rm package.json
npm init -yAdvanced notes
Platform-specific issues:
Git Bash on Windows: Known to freeze after first input. Use npm init -y as workaround.
Windows PowerShell: May need double Ctrl+C to fully exit.
For scripts/CI, always use non-interactive mode:
npm init -yOr with specific values:
npm init -y --scope=@myorg
npm pkg set name="my-package" version="2.0.0"Frequently asked questions
- What does "npm ERR! code ECANCELLED npm ERR! npm init cancelled" mean?
- ECANCELLED indicates the npm init process was intentionally stopped before completion. This happens when you press Ctrl+C (or Ctrl+Break on Windows) during the interactive questionnaire. json based on your answers.
- How do I fix "npm ERR! code ECANCELLED npm ERR! npm init cancelled"?
- The ECANCELLED error occurs when npm init is interrupted, typically by pressing Ctrl+C during the interactive prompts. This is a user-initiated cancellation, not a system error.
- What causes "npm ERR! code ECANCELLED npm ERR! npm init cancelled"?
- User pressed Ctrl+C during prompts Terminal input stream interrupted Prompts appeared frozen (user cancelled)
- Is the "npm ERR! code ECANCELLED npm ERR! npm init cancelled" 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 init Documentation(Official Docs)
- 💬Stack Overflow: npm(Stack Overflow)
- 🐙GitHub: npm(GitHub)