If you no longer need to use a package in your code, we recommend uninstalling it and removing it from your project's dependencies.
To remove a package from your node_modules directory, on the command line, use the uninstall
command. Include the scope if the package is scoped.
npm uninstall <package_name>
npm uninstall <@scope/package_name>
npm uninstall lodash
package.json
dependenciesTo remove a package from the dependencies in package.json
, use the --save
flag. Include the scope if the package is scoped.
npm uninstall --save <package_name>
npm uninstall --save <@scope/package_name>
npm uninstall --save lodash
Note: If you installed a package as a "devDependency" (i.e. with --save-dev
), use --save-dev
to uninstall it:
npm uninstall --save-dev package_name
To confirm that npm uninstall
worked correctly, check that the node_modules
directory no longer contains a directory for the uninstalled package(s).
ls node_modules
dir node_modules
To uninstall an unscoped global package, on the command line, use the uninstall
command with the -g
flag. Include the scope if the package is scoped.
npm uninstall -g <package_name>
npm uninstall -g <@scope/package_name>
For example, to uninstall a package called jshint
, run:
npm uninstall -g jshint
© npm, Inc. and Contributors
Licensed under the npm License.
npm is a trademark of npm, Inc.
https://docs.npmjs.com/uninstalling-packages-and-dependencies