1 ---
2 title: npm-init
3 section: 1
4 description: create a package.json file
5 github_repo: npm/cli
6 github_branch: release/v6
7 github_path: docs/content/commands/npm-init.md
8 redirect_from:
9 - /cli-documentation/v6/cli-commands/init
10 - /cli-documentation/v6/cli-commands/npm-init
11 - /cli-documentation/v6/commands/init
12 - /cli-documentation/v6/commands/npm-init
13 - /cli-documentation/v6/init
14 - /cli-documentation/v6/npm-init
15 - /cli/v6/cli-commands/init
16 - /cli/v6/cli-commands/npm-init
17 - /cli/v6/commands/init
18 - /cli/v6/init
19 - /cli/v6/npm-init
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm init [--force|-f|--yes|-y|--scope]
26 npm init <@scope> (same as `npx <@scope>/create`)
27 npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
28 ```
29
30 ### Examples
31
32 Create a new React-based project using [`create-react-app`](https://npm.im/create-react-app):
33
34 ```bash
35 $ npm init react-app ./my-react-app
36 ```
37
38 Create a new `esm`-compatible package using [`create-esm`](https://npm.im/create-esm):
39
40 ```bash
41 $ mkdir my-esm-lib && cd my-esm-lib
42 $ npm init esm --yes
43 ```
44
45 Generate a plain old package.json using legacy init:
46
47 ```bash
48 $ mkdir my-npm-pkg && cd my-npm-pkg
49 $ git init
50 $ npm init
51 ```
52
53 Generate it without having it ask any questions:
54
55 ```bash
56 $ npm init -y
57 ```
58
59 ### Description
60
61 `npm init <initializer>` can be used to set up a new or existing npm package.
62
63 `initializer` in this case is an npm package named `create-<initializer>`, which will be installed by [`npx`](https://npm.im/npx), and then have its main bin executed -- presumably creating or updating `package.json` and running any other initialization-related operations.
64
65 The init command is transformed to a corresponding `npx` operation as follows:
66
67 - `npm init foo` -> `npx create-foo`
68 - `npm init @usr/foo` -> `npx @usr/create-foo`
69 - `npm init @usr` -> `npx @usr/create`
70
71 Any additional options will be passed directly to the command, so `npm init foo --hello` will map to `npx create-foo --hello`.
72
73 If the initializer is omitted (by just calling `npm init`), init will fall back to legacy init behavior. It will ask you a bunch of questions, and then write a package.json for you. It will attempt to make reasonable guesses based on existing fields, dependencies, and options selected. It is strictly additive, so it will keep any fields and values that were already set. You can also use `-y`/`--yes` to skip the questionnaire altogether. If you pass `--scope`, it will create a scoped package.
74
75 ### See Also
76
77 - [https://github.com/isaacs/init-package-json](https://github.com/isaacs/init-package-json)
78 - [package.json](/cli/v6/configuring-npm/package-json)
79 - [npm version](/cli/v6/commands/npm-version)
80 - [npm scope](/cli/v6/using-npm/scope)