Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI doc correction on npm-init.md #367

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 67 additions & 68 deletions content/cli/v8/commands/npm-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ github_repo: npm/cli
github_branch: release/v8
github_path: docs/lib/content/commands/npm-init.md
redirect_from:
- /cli-documentation/v8/cli-commands/init
- /cli-documentation/v8/cli-commands/npm-init
- /cli-documentation/v8/commands/init
- /cli-documentation/v8/commands/npm-init
- /cli-documentation/v8/init
- /cli-documentation/v8/npm-init
- /cli/v8/cli-commands/init
- /cli/v8/cli-commands/npm-init
- /cli/v8/commands/init
- /cli/v8/init
- /cli/v8/npm-init
- /cli-documentation/v8/cli-commands/init
- /cli-documentation/v8/cli-commands/npm-init
- /cli-documentation/v8/commands/init
- /cli-documentation/v8/commands/npm-init
- /cli-documentation/v8/init
- /cli-documentation/v8/npm-init
- /cli/v8/cli-commands/init
- /cli/v8/cli-commands/npm-init
- /cli/v8/commands/init
- /cli/v8/init
- /cli/v8/npm-init
---

### Synopsis

```bash
npm init <package-spec> (same as `npx <package-spec>)
npm init <package-spec> (same as `npx <package-spec>`)
npm init <@scope> (same as `npx <@scope>/create`)

aliases: create, innit
aliases: create, init
```

### Description
Expand All @@ -41,11 +41,11 @@ running any other initialization-related operations.
The init command is transformed to a corresponding `npm exec` operation as
follows:

* `npm init foo` -> `npm exec create-foo`
* `npm init @usr/foo` -> `npm exec @usr/create-foo`
* `npm init @usr` -> `npm exec @usr/create`
* `npm init @[email protected]` -> `npm exec @usr/[email protected]`
* `npm init @usr/[email protected]` -> `npm exec @usr/[email protected]`
- `npm init foo` -> `npm exec create-foo`
- `npm init @usr/foo` -> `npm exec @usr/create-foo`
- `npm init @usr` -> `npm exec @usr/create`
- `npm init @[email protected]` -> `npm exec @usr/[email protected]`
- `npm init @usr/[email protected]` -> `npm exec @usr/[email protected]`

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
Expand All @@ -55,14 +55,14 @@ 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.

*Note:* if a user already has the `create-<initializer>` package
globally installed, that will be what `npm init` uses. If you want npm
_Note:_ if a user already has the `create-<initializer>` package
globally installed, that will be what `npm init` uses. If you want npm
to use the latest version, or another specific version you must specify
it:

* `npm init foo@latest` # fetches and runs the latest `create-foo` from
- `npm init foo@latest` # fetches and runs the latest `create-foo` from
the registry
* `npm init [email protected]` # runs `[email protected]` specifically
- `npm init [email protected]` # runs `[email protected]` specifically

#### Forwarding additional options

Expand All @@ -73,8 +73,8 @@ To better illustrate how options are forwarded, here's a more evolved
example showing options passed to both the **npm cli** and a create package,
both following commands are equivalent:

- `npm init foo -y --registry=<url> -- --hello -a`
- `npm exec -y --registry=<url> -- create-foo --hello -a`
- `npm init foo -y --registry=<url> -- --hello -a`
- `npm exec -y --registry=<url> -- create-foo --hello -a`

### Examples

Expand Down Expand Up @@ -173,42 +173,42 @@ dot to represent the current directory in that context, e.g: `react-app .`:

#### `yes`

* Default: null
* Type: null or Boolean
- Default: null
- Type: null or Boolean

Automatically answer "yes" to any prompts that npm might print on the
command line.

#### `force`

* Default: false
* Type: Boolean
- Default: false
- Type: Boolean

Removes various protections against unfortunate side effects, common
mistakes, unnecessary performance degradation, and malicious input.

* Allow clobbering non-npm files in global installs.
* Allow the `npm version` command to work on an unclean git repository.
* Allow deleting the cache folder with `npm cache clean`.
* Allow installing packages that have an `engines` declaration requiring a
different version of npm.
* Allow installing packages that have an `engines` declaration requiring a
different version of `node`, even if `--engine-strict` is enabled.
* Allow `npm audit fix` to install modules outside your stated dependency
range (including SemVer-major changes).
* Allow unpublishing all versions of a published package.
* Allow conflicting peerDependencies to be installed in the root project.
* Implicitly set `--yes` during `npm init`.
* Allow clobbering existing values in `npm pkg`
* Allow unpublishing of entire packages (not just a single version).
- Allow clobbering non-npm files in global installs.
- Allow the `npm version` command to work on an unclean git repository.
- Allow deleting the cache folder with `npm cache clean`.
- Allow installing packages that have an `engines` declaration requiring a
different version of npm.
- Allow installing packages that have an `engines` declaration requiring a
different version of `node`, even if `--engine-strict` is enabled.
- Allow `npm audit fix` to install modules outside your stated dependency
range (including SemVer-major changes).
- Allow unpublishing all versions of a published package.
- Allow conflicting peerDependencies to be installed in the root project.
- Implicitly set `--yes` during `npm init`.
- Allow clobbering existing values in `npm pkg`
- Allow unpublishing of entire packages (not just a single version).

If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!

#### `scope`

* Default: the scope of the current project, if any, or ""
* Type: String
- Default: the scope of the current project, if any, or ""
- Type: String

Associate an operation with a scope for a scoped registry.

Expand All @@ -234,22 +234,21 @@ This will also cause `npm init` to create a scoped package.
npm init --scope=@foo --yes
```


#### `workspace`

* Default:
* Type: String (can be set multiple times)
- Default:
- Type: String (can be set multiple times)

Enable running a command in the context of the configured workspaces of the
current project while filtering by running only the workspaces defined by
this configuration option.

Valid values for the `workspace` config are either:

* Workspace names
* Path to a workspace directory
* Path to a parent workspace directory (will result in selecting all
workspaces within that folder)
- Workspace names
- Path to a workspace directory
- Path to a parent workspace directory (will result in selecting all
workspaces within that folder)

When set for the `npm init` command, this may be set to the folder of a
workspace which does not yet exist, to create the folder and set it up as a
Expand All @@ -259,34 +258,34 @@ This value is not exported to the environment for child processes.

#### `workspaces`

* Default: null
* Type: null or Boolean
- Default: null
- Type: null or Boolean

Set to true to run the command in the context of **all** configured
workspaces.

Explicitly setting this to false will cause commands like `install` to
ignore workspaces altogether. When not set explicitly:

- Commands that operate on the `node_modules` tree (install, update, etc.)
will link workspaces into the `node_modules` folder. - Commands that do
other things (test, exec, publish, etc.) will operate on the root project,
_unless_ one or more workspaces are specified in the `workspace` config.
- Commands that operate on the `node_modules` tree (install, update, etc.)
will link workspaces into the `node_modules` folder. - Commands that do
other things (test, exec, publish, etc.) will operate on the root project,
_unless_ one or more workspaces are specified in the `workspace` config.

This value is not exported to the environment for child processes.

#### `workspaces-update`

* Default: true
* Type: Boolean
- Default: true
- Type: Boolean

If set to true, the npm cli will run an update after operations that may
possibly change the workspaces installed to the `node_modules` folder.

#### `include-workspace-root`

* Default: false
* Type: Boolean
- Default: false
- Type: Boolean

Include the workspace root when workspaces are enabled for a command.

Expand All @@ -298,10 +297,10 @@ This value is not exported to the environment for child processes.

### See Also

* [package spec](/cli/v8/using-npm/package-spec)
* [init-package-json module](http://npm.im/init-package-json)
* [package.json](/cli/v8/configuring-npm/package-json)
* [npm version](/cli/v8/commands/npm-version)
* [npm scope](/cli/v8/using-npm/scope)
* [npm exec](/cli/v8/commands/npm-exec)
* [npm workspaces](/cli/v8/using-npm/workspaces)
- [package spec](/cli/v8/using-npm/package-spec)
- [init-package-json module](http://npm.im/init-package-json)
- [package.json](/cli/v8/configuring-npm/package-json)
- [npm version](/cli/v8/commands/npm-version)
- [npm scope](/cli/v8/using-npm/scope)
- [npm exec](/cli/v8/commands/npm-exec)
- [npm workspaces](/cli/v8/using-npm/workspaces)
Loading