Koa.js Development - Koa.js

How to start Koa.js?

Node and node package manager (npm) are to be installed before using koa framework. Node setup and npm can be installed with the commands:

The output produced is as:

The version of the node should be always above 6.5.0

What is Node Package Manager (npm)?

Node Package Manager is a collection of code packages of web and mobile apps, routers, robots, and include other specifications from JavaScript. npm facilitates in accessing and installation of the packages. The list of npm packages can be viewed at npmJS.

How to use npm?

Npm can be used in two ways to install a package – Globally and Locally

Globally – Facilitates in installing CLI based packages and development tools. A package can be installed globally by the code:

Locally – Facilitates in installing libraries and frameworks. Locally installed package enables to use only within the directory in which installed. A package can be installed locally by the code:

A package file package.json file need to be provided to create a project using npm. Packae.json provides complete information about the project, and can be set up easily by npm. To set up a development project:

1.A new folder with the name hello-world need to created and cd the terminal/cmd into the hello-world folder.

npm init info

2.Package.json file is created using npm by following code:

npm init info

Provide the name under “Author Name” field.

3.Package.json file is set up. Koa can now be installed and added to package.json file by the command:

Run the following code to check and confirm the installation of Koa.

A tool nodemon can be installed from npm, which enabled development process much easier. nodemon facilitates in restarting the sever whenever a change is made to any of the files automatically, avoiding the manual restart. Nodemon is installed by the command:

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Koa.js Topics