How to fix npm ERR! code ECANCELLED npm ERR! npm init cancelled in npm

npmINTERMEDIATELOWUpdated Dec 3, 2025· 141 views

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
  1. Use non-interactive mode
  2. Complete the interactive prompts
  3. Configure npm defaults
  4. Fix frozen prompts
npm — error
npm init -y
# or
npm init --yes
npm ERR! code ECANCELLED
npm 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

  1. User pressed Ctrl+C during prompts
  2. Terminal input stream interrupted
  3. Prompts appeared frozen (user cancelled)
  4. Input piped incorrectly to npm init

How to fix "npm ERR! code ECANCELLED npm ERR! npm init cancelled"

1Use non-interactive mode

Skip all prompts with -y flag:

bash
npm init -y
# or
npm init --yes

This creates package.json with defaults:
- name: current directory name
- version: 1.0.0
- main: index.js

2Complete the interactive prompts

If you want to fill in details, answer all prompts:

bash
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) yes

Don't press Ctrl+C until you see "Is this ok?"

3Configure npm defaults

Set defaults so npm init -y uses your info:

bash
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.

4Fix frozen prompts

If prompts freeze (known Node.js 8.1.0 bug):

bash
# Check Node version
node --version

# If 8.1.0, upgrade:
nvm install 20
nvm use 20

# Then retry
npm init
5Clean up partial files

If cancellation left partial files:

bash
# Check if package.json exists
ls package.json

# If incomplete, remove and retry
rm package.json
npm init -y

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

bash
npm init -y

Or with specific values:

bash
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