NPM basics of Global Packages

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 webpa…


This content originally appeared on DEV Community and was authored by Mehluli Hikwa

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

NPM Official Documentation


This content originally appeared on DEV Community and was authored by Mehluli Hikwa


Print Share Comment Cite Upload Translate Updates
APA

Mehluli Hikwa | Sciencx (2021-03-12T11:43:35+00:00) NPM basics of Global Packages. Retrieved from https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/

MLA
" » NPM basics of Global Packages." Mehluli Hikwa | Sciencx - Friday March 12, 2021, https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/
HARVARD
Mehluli Hikwa | Sciencx Friday March 12, 2021 » NPM basics of Global Packages., viewed ,<https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/>
VANCOUVER
Mehluli Hikwa | Sciencx - » NPM basics of Global Packages. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/
CHICAGO
" » NPM basics of Global Packages." Mehluli Hikwa | Sciencx - Accessed . https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/
IEEE
" » NPM basics of Global Packages." Mehluli Hikwa | Sciencx [Online]. Available: https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/. [Accessed: ]
rf:citation
» NPM basics of Global Packages | Mehluli Hikwa | Sciencx | https://www.scien.cx/2021/03/12/npm-basics-of-global-packages/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.