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.
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.
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 "[email protected]"
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 -yPlatform-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"npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"