The information shared below is npm basics of global packages which are partially hidden or difficult to find in the docs page. I hope they help. Lets dabble.
1) NPM install global packages - example to install Webpack globally
npm install -g webpack
2) Listing globally installed NPM packages and version
npm list -g --depth=0
The result will look something like this:
C:\Users\thatAfro\AppData\Roaming\npm
+-- @angular/cli@8.3.29
+-- ionic@5.4.16
`-- webpack@4.46.0
3) Update Global Packages
Find/View packages which need to be updated:
npm outdated -g --depth=0
The result will look something like this:
C:\Users\thatAfro>npm outdated -g --depth=0
Package Current Wanted Latest Location
npm 6.1.0 6.2.0 6.2.0
webpack 4.12.1 4.16.1 4.16.1
Update all global packages
npm update -g
In some cases you may want to update packages one at a time, so you can do this as follows:
npm update -g
For example updating webpack, it would look like this
npm update -g webpack
4) Uninstall Global Packages
npm uninstall -g
For example uninstall webpack, it would look like this
npm uninstall -g webpack
5) Uninstall npm modules in node.js
As commonly known, any npm module can be installed by running a simple command: npm install
The command is simply npm uninstall
The nodejs documents have all the commands that you need to know with npm.
A local install will be in the node_modules/ directory of your application. This won't affect the application if a module remains there with no references to it.
If you’re removing a global package however, any applications referencing it will crash.
Here are different options:
npm uninstall removes the module from node_modules, but not package.json
npm uninstall --save also removes it from dependencies in package.json
npm uninstall --save-dev also removes it from devDependencies in package.json
npm -g uninstall --save also removes it globally.
For further help with npm, you can visit the docs page
Top comments (0)