Node.js Mongoose – Installation

In this tutorial, we shall learn to install Mongoose package using npm (Node Package Manager).

Prerequisites

It is assumed that you have already installed Node.js and MongoDB. If incase not, then you may refer the below links.

ADVERTISEMENT

Installation

To install Mongoose package, use npm (Node Package Manager). Open a terminal and run the following command.

$ npm install mongoose
$ npm install mongoose
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN mongoose_tutorial@1.0.0 No repository field.

+ mongoose@5.0.3
added 20 packages in 3.936s

Using Mongoose

To use Mongoose in Node.js Script File, include require statement with mongoose package.

var mongoose = require('mongoose');

Conclusion :

In this tutorial, we have learnt how to install a Mongoose package and start using its reference.