Update uninstalling-packages-and-dependencies.mdx (#182)
Updating this documentation to reflect the updated `npm uninstall` functionality that no longer requires `--save-dev` or `--save` for removing packages from your `package.json` and other npm files.
Eric Allen committed
Aug 29, 2022 at 08:36 UTC
083285788f83df45e311d5e398d699ab97641ad5
1 file changed
+11
-21
content/packages-and-modules/getting-packages-from-the-registry/uninstalling-packages-and-dependencies.mdx
+11
-21
@@ -13,6 +13,12 @@ If you no longer need to use a package in your code, we recommend uninstalling i
13
14
To remove a package from your node_modules directory, on the command line, use the [`uninstall` command][cli-uninstall]. Include the scope if the package is scoped.
15
16
+This uninstalls a package, completely removing everything npm installed on its behalf.
17
+
18
+It also removes the package from the dependencies, devDependencies, optionalDependencies, and peerDependencies objects in your package.json.
19
+
20
+Further, if you have an npm-shrinkwrap.json or package-lock.json, npm will update those files as well.
21
+
22
#### Unscoped package
23
24
```
@@ -32,35 +38,19 @@ npm uninstall <@scope/package_name>
38
npm uninstall lodash
39
```
40
35
-### Removing a local package from the `package.json` dependencies
41
+### Removing a local package without removing it from package.json
42
37
-To remove a package from the dependencies in `package.json`, use the `--save` flag. Include the scope if the package is scoped.
38
-
39
-#### Unscoped package
43
+Using the `--no-save` will tell npm not to remove the package from your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files.
44
41
-```
42
-npm uninstall --save <package_name>
43
-```
44
-
45
-#### Scoped package
46
-
47
-```
48
-npm uninstall --save <@scope/package_name>
49
-```
50
-
51
-#### Example
45
+### Example
46
47
```
54
-npm uninstall --save lodash
48
+npm uninstall --no-save lodash
49
```
50
51
<Note>
52
59
-**Note:** If you installed a package as a "devDependency" (i.e. with `--save-dev`), use `--save-dev` to uninstall it:
60
-
61
-```
62
-npm uninstall --save-dev package_name
63
-```
53
+`--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.
54
55
</Note>
56