How to remove a module package by PHP composer?

You can remove the specific module package from the composer by using composer syntax.

Run the given command from the root of your project.

composer remove <vendor-name>/<package-name>

Let’s say your module name is, magento/module-elasticsearch and you want to remove it from the system,

Run command,
composer remove magento/module-elasticsearch
In the above command, magento is the VendorName while the PackageName is module-elasticsearch.

This way you can remove the given module from the system.

Once the module is successfully removed, the composer.lock file also updated and remove the history of your module content from it.