1NPM-UNINSTALL(1) NPM-UNINSTALL(1)
2
3
4
6 npm-uninstall - Remove a package
7
8 Synopsis
9 npm uninstall [<@scope>/]<pkg>...
10
11 aliases: unlink, remove, rm, r, un
12
13 Description
14 This uninstalls a package, completely removing everything npm installed
15 on its behalf.
16
17 It also removes the package from the dependencies, devDependencies, op‐
18 tionalDependencies, and peerDependencies objects in your package.json.
19
20 Further, if you have an npm-shrinkwrap.json or package-lock.json, npm
21 will update those files as well.
22
23 --no-save will tell npm not to remove the package from your pack‐
24 age.json, npm-shrinkwrap.json, or package-lock.json files.
25
26 --save or -S will tell npm to remove the package from your pack‐
27 age.json, npm-shrinkwrap.json, and package-lock.json files. This is the
28 default, but you may need to use this if you have for instance
29 save=false in your npmrc file
30
31 In global mode (ie, with -g or --global appended to the command), it
32 uninstalls the current package context as a global package. --no-save
33 is ignored in this case.
34
35 Scope is optional and follows the usual rules for npm help scope.
36
37 Examples
38 npm uninstall sax
39
40 sax will no longer be in your package.json, npm-shrinkwrap.json, or
41 package-lock.json files.
42
43 npm uninstall lodash --no-save
44
45 lodash will not be removed from your package.json, npm-shrinkwrap.json,
46 or package-lock.json files.
47
48 Configuration
49 save
50 • Default: true unless when using npm update where it defaults to
51 false
52
53 • Type: Boolean
54
55
56 Save installed packages to a package.json file as dependencies.
57
58 When used with the npm rm command, removes the dependency from pack‐
59 age.json.
60
61 Will also prevent writing to package-lock.json if set to false.
62
63 global
64 • Default: false
65
66 • Type: Boolean
67
68
69 Operates in "global" mode, so that packages are installed into the pre‐
70 fix folder instead of the current working directory. See npm help fold‐
71 ers for more on the differences in behavior.
72
73 • packages are installed into the {prefix}/lib/node_modules folder,
74 instead of the current working directory.
75
76 • bin files are linked to {prefix}/bin
77
78 • man pages are linked to {prefix}/share/man
79
80
81 workspace
82 • Default:
83
84 • Type: String (can be set multiple times)
85
86
87 Enable running a command in the context of the configured workspaces of
88 the current project while filtering by running only the workspaces de‐
89 fined by this configuration option.
90
91 Valid values for the workspace config are either:
92
93 • Workspace names
94
95 • Path to a workspace directory
96
97 • Path to a parent workspace directory (will result in selecting all
98 workspaces within that folder)
99
100
101 When set for the npm init command, this may be set to the folder of a
102 workspace which does not yet exist, to create the folder and set it up
103 as a brand new workspace within the project.
104
105 This value is not exported to the environment for child processes.
106
107 workspaces
108 • Default: null
109
110 • Type: null or Boolean
111
112
113 Set to true to run the command in the context of all configured
114 workspaces.
115
116 Explicitly setting this to false will cause commands like install to
117 ignore workspaces altogether. When not set explicitly:
118
119 • Commands that operate on the node_modules tree (install, update,
120 etc.) will link workspaces into the node_modules folder. - Commands
121 that do other things (test, exec, publish, etc.) will operate on
122 the root project, unless one or more workspaces are specified in
123 the workspace config.
124
125
126 This value is not exported to the environment for child processes.
127
128 include-workspace-root
129 • Default: false
130
131 • Type: Boolean
132
133
134 Include the workspace root when workspaces are enabled for a command.
135
136 When false, specifying individual workspaces via the workspace config,
137 or all workspaces via the workspaces flag, will cause npm to operate
138 only on the specified workspaces, and not on the root project.
139
140 This value is not exported to the environment for child processes.
141
142 install-links
143 • Default: false
144
145 • Type: Boolean
146
147
148 When set file: protocol dependencies will be packed and installed as
149 regular dependencies instead of creating a symlink. This option has no
150 effect on workspaces.
151
152 See Also
153 • npm help prune
154
155 • npm help install
156
157 • npm help folders
158
159 • npm help config
160
161 • npm help npmrc
162
163
164
165 November 2023 NPM-UNINSTALL(1)