Javatpoint Logo
Javatpoint Logo

Npm uninstall command

The default package manager for js or Node.js is NPM (Node Package Manager). It installs together with the installation of Node.js and controls all the packages. Any package we install into our project using the npm client on the command prompt is installed in the node modules folder, and its version information is replicated in the package.json file.

Working with packages is made possible through the Node Package Manager (NPM), which offers various commands. We can use the npm uninstall command to remove a package from the computer.

But we should not uninstall a global package and a dev dependent like an ordinary package or dependency. Now we describe how to remove an ordinary package, a global package, as well as a developer dependency.

How to remove the npm ordinary package

  • The npm uninstall command is used to eliminate a package from our active Node project:

The following image shows we uninstall the command in the command prompt.

Npm uninstall command

The synonyms for the npm uninstall command are npm un, npm rm, npm remove, and npm unlink.

Using the npm uninstalls command, the package and its dependencies are fully removed from the active project. The package.json file is also updated.

  • The npm-demo project's express module can be removed using the following command:

Npm uninstall command
  • The express package was already deleted, as can be seen by looking at the package.json file.
  • We can see that Express is no longer present.
  • Because there is no dependency, there is no longer a dependency key.

Use npm Uninstall to Remove a Development Dependency.

A package that is only used for development is a dev dependency.

We must include the following commands as a dev argument to the npm uninstall command. It is used before specifying the package name to remove a dev dependency.

The following commands are the basic syntaxes for achieving uninstallation of dependency.

OR


Npm uninstall command

The location (folder) where the dependent must be used to perform the command.

  • Use Nodemon to show us how to get rid of a development requirement.
  • Any time it notices a change in a folder or a file while in development, Nodemon enables the NodeJS app to reload automatically.
  • We can see in the command that Nodemon is marked as a development dependency.

The following command uses to get rid of nodemon.

We can see that the package no longer contains Nodemon in the json file.

Npm uninstall command

Similarly, other dependencies are uninstalled and removed from other commands in the command prompt. The following commands help to remove the required dependencies.

  • --save or -S: the command helps to uninstall the package from the dependencies. The following command is used to remove dependency packages.
  • --save-optional or -O: the command helps to uninstall the package from the optional Dependencies. The following command is used to remove optional packages.

Npm uninstall command

Conclusion

For the Node Js/javascript platform, the command line helps to uninstall npm step by step for operations. It helps to uninstall npm packages and other related dependencies in a single command line using a command prompt. The npm uninstall commands for the javascript functionality in all web-related applications.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA