workspace

npm init

Creates a new package.json interactively, or when given an initializer (e.g. `npm init vite@latest`) delegates to `npm exec create-<initializer>`. `-y` accepts all defaults.

npm init [<initializer>] | npm init -y

Common flags

Flag Purpose
--yes (-y) Skip prompts and generate a default package.json
--scope <@scope> Create a scoped package
--workspace <path> (-w) Create a new workspace under the given path
-w <path> -y Common combo to scaffold a workspace non-interactively

Examples

npm init -y

Create a default package.json with no prompts

npm init vite@latest my-app

Delegate to create-vite for scaffolding

npm init -w packages/utils -y

Create a new workspace at packages/utils

Gotcha

`npm init ` is sugar for `npm exec create-` — it will install and run the create-* package from the registry. Use `npm init @scope/name` for a scoped initializer such as `@vue/create`.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM