reggi/overrides
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-uninstall |
| 3 | section: 1 |
| 4 | description: Remove a package |
| 5 | github_repo: npm/cli |
| 6 | github_branch: latest |
| 7 | github_path: docs/lib/content/commands/npm-uninstall.md |
| 8 | redirect_from: |
| 9 | - /cli-commands/npm-uninstall |
| 10 | - /cli-commands/uninstall |
| 11 | - /cli-documentation/cli-commands/npm-uninstall |
| 12 | - /cli-documentation/cli-commands/uninstall |
| 13 | - /cli-documentation/commands/npm-uninstall |
| 14 | - /cli-documentation/commands/uninstall |
| 15 | - /cli-documentation/npm-uninstall |
| 16 | - /cli-documentation/uninstall |
| 17 | - /cli-documentation/v10/cli-commands/npm-uninstall |
| 18 | - /cli-documentation/v10/cli-commands/uninstall |
| 19 | - /cli-documentation/v10/commands/npm-uninstall |
| 20 | - /cli-documentation/v10/commands/uninstall |
| 21 | - /cli-documentation/v10/npm-uninstall |
| 22 | - /cli-documentation/v10/uninstall |
| 23 | - /cli/cli-commands/npm-uninstall |
| 24 | - /cli/cli-commands/uninstall |
| 25 | - /cli/commands/npm-uninstall |
| 26 | - /cli/commands/uninstall |
| 27 | - /cli/npm-uninstall |
| 28 | - /cli/uninstall |
| 29 | - /cli/v10/cli-commands/npm-uninstall |
| 30 | - /cli/v10/cli-commands/uninstall |
| 31 | - /cli/v10/commands/uninstall |
| 32 | - /cli/v10/npm-uninstall |
| 33 | - /cli/v10/uninstall |
| 34 | - /commands/npm-uninstall |
| 35 | - /commands/uninstall |
| 36 | --- |
| 37 | |
| 38 | ### Synopsis |
| 39 | |
| 40 | ```bash |
| 41 | npm uninstall [<@scope>/]<pkg>... |
| 42 | |
| 43 | aliases: unlink, remove, rm, r, un |
| 44 | ``` |
| 45 | |
| 46 | ### Description |
| 47 | |
| 48 | This uninstalls a package, completely removing everything npm installed on its behalf. |
| 49 | |
| 50 | It also removes the package from the `dependencies`, `devDependencies`, `optionalDependencies`, and `peerDependencies` objects in your `package.json`. |
| 51 | |
| 52 | Further, if you have an `npm-shrinkwrap.json` or `package-lock.json`, npm will update those files as well. |
| 53 | |
| 54 | `--no-save` will tell npm not to remove the package from your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files. |
| 55 | |
| 56 | `--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 |
| 57 | |
| 58 | 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. |
| 59 | |
| 60 | Scope is optional and follows the usual rules for [`scope`](/cli/v10/using-npm/scope). |
| 61 | |
| 62 | ### Examples |
| 63 | |
| 64 | ```bash |
| 65 | npm uninstall sax |
| 66 | ``` |
| 67 | |
| 68 | `sax` will no longer be in your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files. |
| 69 | |
| 70 | ```bash |
| 71 | npm uninstall lodash --no-save |
| 72 | ``` |
| 73 | |
| 74 | `lodash` will not be removed from your `package.json`, `npm-shrinkwrap.json`, or `package-lock.json` files. |
| 75 | |
| 76 | ### Configuration |
| 77 | |
| 78 | #### `save` |
| 79 | |
| 80 | - Default: `true` unless when using `npm update` where it defaults to `false` |
| 81 | - Type: Boolean |
| 82 | |
| 83 | Save installed packages to a `package.json` file as dependencies. |
| 84 | |
| 85 | When used with the `npm rm` command, removes the dependency from `package.json`. |
| 86 | |
| 87 | Will also prevent writing to `package-lock.json` if set to `false`. |
| 88 | |
| 89 | #### `global` |
| 90 | |
| 91 | - Default: false |
| 92 | - Type: Boolean |
| 93 | |
| 94 | Operates in "global" mode, so that packages are installed into the `prefix` folder instead of the current working directory. See [folders](/cli/v10/configuring-npm/folders) for more on the differences in behavior. |
| 95 | |
| 96 | - packages are installed into the `{prefix}/lib/node_modules` folder, instead of the current working directory. |
| 97 | - bin files are linked to `{prefix}/bin` |
| 98 | - man pages are linked to `{prefix}/share/man` |
| 99 | |
| 100 | #### `workspace` |
| 101 | |
| 102 | - Default: |
| 103 | - Type: String (can be set multiple times) |
| 104 | |
| 105 | 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. |
| 106 | |
| 107 | Valid values for the `workspace` config are either: |
| 108 | |
| 109 | - Workspace names |
| 110 | - Path to a workspace directory |
| 111 | - Path to a parent workspace directory (will result in selecting all workspaces within that folder) |
| 112 | |
| 113 | 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 brand new workspace within the project. |
| 114 | |
| 115 | This value is not exported to the environment for child processes. |
| 116 | |
| 117 | #### `workspaces` |
| 118 | |
| 119 | - Default: null |
| 120 | - Type: null or Boolean |
| 121 | |
| 122 | Set to true to run the command in the context of **all** configured workspaces. |
| 123 | |
| 124 | Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly: |
| 125 | |
| 126 | - 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. |
| 127 | |
| 128 | This value is not exported to the environment for child processes. |
| 129 | |
| 130 | #### `include-workspace-root` |
| 131 | |
| 132 | - Default: false |
| 133 | - Type: Boolean |
| 134 | |
| 135 | Include the workspace root when workspaces are enabled for a command. |
| 136 | |
| 137 | When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project. |
| 138 | |
| 139 | This value is not exported to the environment for child processes. |
| 140 | |
| 141 | #### `install-links` |
| 142 | |
| 143 | - Default: false |
| 144 | - Type: Boolean |
| 145 | |
| 146 | When set file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink. This option has no effect on workspaces. |
| 147 | |
| 148 | ### See Also |
| 149 | |
| 150 | - [npm prune](/cli/v10/commands/npm-prune) |
| 151 | - [npm install](/cli/v10/commands/npm-install) |
| 152 | - [npm folders](/cli/v10/configuring-npm/folders) |
| 153 | - [npm config](/cli/v10/commands/npm-config) |
| 154 | - [npmrc](/cli/v10/configuring-npm/npmrc) |