npm init: Usage, Options & Common Errors
Create a package.json or run a project initializer.
npm init creates a package.json interactively, or, given an initializer name, runs the matching create-* package - the same machinery behind npm create.
What it does
With no argument, prompts for fields and writes package.json (use -y to accept defaults non-interactively). With an initializer like npm init vite, it downloads and runs create-vite via the npm exec machinery.
Common usage
Terminal
npm init -y # write package.json with defaults
npm init # interactive prompts
npm init vite@latest # run create-vite
npm init @scope/tool # run @scope/create-toolCommon CI error: init hangs on prompts
A scripted npm init blocks waiting for interactive input and the job times out. Always pass -y (or --yes) in non-interactive environments so it accepts defaults instead of prompting.
.github/workflows/ci.yml
npm init -yRelated guides
npm install: Usage, Options & Common CI ErrorsWhat npm install does, the flags you actually use, and the install failures that break CI builds - ERESOLVE,…
npm exec & npx: Usage, Options & Common Errorsnpm exec (and npx) runs a package binary, installing it on demand. Usage, the -- separator, --yes for CI, and…
npx "<command>: not found" / "npm ERR! 404" - Fix Missing npx Binary in CIFix npx failing in CI - "<command>: not found" or a 404 fetching the package - when the tool is not installed…