NodeJS Series Part 5: Installing, Uninstalling, Updating Modules

Do you remember what we did previously? We created a Port Listener that listens to a port and gets a response. In that article, we used a module named “http” to send a request and get a response.

I will now talk about “Modules” and how to use them.

MODULES

The Node Package Manager consists of many modules that can be downloaded and used in your project. The list of repository can be accessed from: https://www.npmjs.com/

You can however specify if a module will be used locally or globally.

What does that mean?

Global means it can be used in other projects as well. By default, Local mode is preferred.

Note: You can install a module globally by adding “-g” parameter.

Important Note: Before installing a module, make sure you create a folder in a near destination. I will be using a test folder in my desktop.

Installing a Module

Installing a module is easy, let's get back to https://www.npmjs.com/ and select a module to install browserify:

node8

Now open your Nodejs Command Prompt and head to the folder you just created.

node9

Now add these lines to install browserify in the specified folder:

  1. npm install browserify  

Press Enter and let it download the dependencies and the browserify module itself.

node10

Once it's finished, you can have a look at your folder structure being replaced by the browserify module and its dependencies.

UnInstalling a Module

Since we installed Browserify, why don't we use the same module?

To Uninstall a module you simply write the following command:

  1. npm uninstall browserify  

node11

And it will uninstall browserify and its dependencies.

node12

You shall see in your project folder that the modules are gone.

Updating a Module

Why do we even update? To get the latest version of course!

If you previously used an older module with a new version available, you'll need to update it in no time.

To update a module you simply write the following command:

  1. npm update browserify  

The rest is up to NPM. It will update the specified module. Since we uninstalled the browserify module previously you can test it after you install it again:

node13

This article exlained a great deal about managing modules. I hope it was useful information for you Wizards.

Up Next
    Ebook Download
    View all
    Learn
    View all
    Araf Global is a software consultancy company founded in 2016 focusing on cutting edge technologies.