How to Remove and Unpublish Packages Using npm CLI Commands
The last tutorial was a guide to creating and managing your npm tokens, the tutorial you are about to read will show you how you can remove a package as well as how to get your package unpublished.
Npm-uninstall
This npm uninstall command will remove a package.
Synopsis
npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|-D|--save-dev|-O|--save-optional|--no-save] aliases: remove, rm, r, un, unlink
description
This command will uninstall a package, doing this will completely remove everything npm installed because of that package.
Example;
Npm uninstall angular-cli, will remove the angular cli as well as all the dependencies that were installed for it to work on your environment.
When you run this command in global mode, it will uninstall the current package context as a global package.
There are four optional flags that you can pass to the command, they are:
-S, --save: The package will be removed from your dependencies.
-D, --save-dev: The package will be removed from your devDependencies.
-O, --save-optional: The package will be removed from your optionalDependencies.
--no-save: The package will not be removed from your package.json file.
Additionally, if you have an npm-shrinkwrap.json file, it will also be updated.
Here is an example:
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
npm-unpublish
The npm unpublish command removes a package from the registry.
Synopsis
npm unpublish [<@scope>/]<pkg>[@<version>]
Warning
Generally, it is considered a bad behavior to remove versions of a library that others are depending on!
You should consider using the deprecate command instead, if what you intend is to encourage users to upgrade.
Description
The npm unpublish command removes a package version from the registry, thus deleting its entry and removing the tarball.
If you do not specify a version, or if all the versions are removed then the root package entry is removed from the registry entirely.
Even when a package version is unpublished, that specific name and version combination can never be reused in the npm registry. For you to publish the package again, a new version number has to be used.
Using the default registry (registry.npmjs.org), the unpublish command is only allowed with versions published in the last 72 hours. Similarly, new versions of unpublished packages cannot be republished until 72 hours have passed. In the case where you are trying to unpublish a version published longer ago than that, you should contact [email protected].
Previous:
How to Manage Authentication Tokens Using npm Token Command.
Next:
How to Update Packages and Bump Versions Using npm CLI Commands.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/npm/npm-uninstall-and-npm-unpublish-cli-commands.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics