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

fix(docs): clean up npm uninstall docs #2464

Closed
wants to merge 8 commits into from
Closed
47 changes: 25 additions & 22 deletions docs/content/commands/npm-uninstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Remove a package
### Synopsis

```bash
npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|-D|--save-dev|-O|--save-optional|--no-save]
npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|--no-save]

aliases: remove, rm, r, un, unlink
```
Expand All @@ -17,40 +17,43 @@ aliases: remove, rm, r, un, unlink
This uninstalls a package, completely removing everything npm installed
on its behalf.

Example:
It also removes the package from the `dependencies`, `devDependencies`,
`optionalDependencies`, and `peerDependencies` objects in your
`package.json`.

```bash
npm uninstall sax
```
Futher, if you have an `npm-shrinkwrap.json` or `package-lock.json`, npm
will update those files as well.

In global mode (ie, with `-g` or `--global` appended to the command),
it uninstalls the current package context as a global package.

`npm uninstall` takes 3 exclusive, optional flags which save or update
the package version in your main package.json:
`--no-save` will tell npm not to remove the package from your
`package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files.

* `-S, --save`: Package will be removed from your `dependencies`.
`--save` or `-S` will tell npm to remove the package from your
`package.json`, `npm-shrinkwrap.json`, and `package-lock.json` files.
This is the default, but you may need to use this if you have for
instance `save=false` in your `npmrc` file

* `-D, --save-dev`: Package will be removed from your `devDependencies`.
In global mode (ie, with `-g` or `--global` appended to the command),
it uninstalls the current package context as a global package.
`--no-save` is ignored in this case.

* `-O, --save-optional`: Package will be removed from your `optionalDependencies`.
Scope is optional and follows the usual rules for [`scope`](/using-npm/scope).

* `--no-save`: Package will not be removed from your `package.json` file.
### Examples

Further, if you have an `npm-shrinkwrap.json` then it will be updated as
well.
```bash
npm uninstall sax
```

Scope is optional and follows the usual rules for [`scope`](/using-npm/scope).
sax will no longer be in your `package.json`, `npm-shrinkwrap.json`, or
wraithgar marked this conversation as resolved.
Show resolved Hide resolved
`package-lock.json` files.

Examples:
```bash
npm uninstall sax --save
npm uninstall @myorg/privatepackage --save
npm uninstall node-tap --save-dev
npm uninstall dtrace-provider --save-optional
npm uninstall lodash --no-save
```

lodash will not be removed from your `package.json`,
wraithgar marked this conversation as resolved.
Show resolved Hide resolved
`npm-shrinkwrap.json`, or `package-lock.json` files.

### See Also

* [npm prune](/commands/npm-prune)
Expand Down
2 changes: 1 addition & 1 deletion lib/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const completion = require('./utils/completion/installed-shallow.js')

const usage = usageUtil(
'uninstall',
'npm uninstall [<@scope>/]<pkg>[@<version>]... [--save-prod|--save-dev|--save-optional] [--no-save]'
'npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|--no-save]'
)

const cmd = (args, cb) => rm(args).then(() => cb()).catch(cb)
Expand Down