To run our application properly, we need some external dependencies. We can get these dependencies by using a package manager, like npm or yarn.
Some of the packages that we need are as follows:
- koa: Our base framework
- koa-router: RESTful routing middleware for Koa
- koa-logger: Development-style logger middleware for Koa
- koa-body: Request body parser middleware for Koa
- mongoose: Object data modelling (ODM) library for MongoDB and Node.js
- joi: Object schema validation library
To install these dependencies into our application using npm, we use the following command:
npm install --save koa koa-router koa-logger koa-body mongoose joi
The --save flag specifies that we want to save these packages as dependencies in our package.json file.
With newer versions of npm, you do not need to specify the --save flag for installed packages to be added as dependencies in the package.json file. You can simply install and save dependencies with npm install or npm i.