Open In App

How local installation of a dependency done ?

Last Updated : 09 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The local installation of dependencies in Node.js is done by putting the local dependencies in a single place and running some simple commands from the terminal to install dependencies. A local dependency can’t be accessed outside of the directory. All the local dependencies of a project are usually inside of a file called package.json

Prerequisites:

  • Node js: If you don’t have Node.js installed click here to know how to install first.

Syntax:

npm install <package-name>

Steps to install any local dependencies:

Step 1: Create a local folder where you want to put all your local dependencies for a particular project:

mkdir foldername

Step 2: After creating the folder successfully, move to that folder:

cd foldername

Step 3: Initialise an empty node project by running the command:

npm init -y

This will create a file called package.json which will store all the dependencies you create.

Step 4: Run the following command, this will install your desired dependency in your project. Replace the package name with dependency.

npm install <pkg-name>

After running the command your local dependency would be installed. To confirm if dependency is installed successfully or not check the package.json file

You would be able to see the module installed as an object in the dependencies property. 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads