Welcome to Koa(tutorial -02)

In here we are talking about how to create a server using koa.js

First of all we should install node.js to computer. then we can see node version using command prompt. after opening prompt we should type node -v and press enter the we can see node version.

after that we should make a directory or new folder and open a terminal using visual code of any other code editor. then we should create package.json for that directory or the folder.

in next step we may type npm init in terminal and answer certain questions as follows.

In next step we should install koa and nodemon to pc. for that we also type npm install koa and npm install -g nodemonin command prompt and hit enter.

then we should make a new JS file(app.js) and add start and dev command in package.json as below

next we type our code in app.js file.

after that step we should run that using npm run dev

then we can see our message in our port. we can go that using localhost:3200

And main thing is Koa don’t came with a inbuild router so we have to install koa router as well. for that we have to type npm i koa-router

After that we can use that as middleware. so we can edit app.js file below as well.

After running the code we can also see same message in our port.

Thank you!

--

--

--

I am a 3rd-year Software Engineering undergraduate at the Sri Lanka Institute of Information Technology- SLIIT, Reg.no : IT19111766

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

All you need to know about React.

Beginner’s Guide to Debugging in NodeJS Applications

More JavaScript Basic things you should know as a web developer.

Are Generics a Good Enough Reason To Use TypeScript?

Building the future of Moneyfarm UI

Drop down tree-view in angular using prime ng tree

Scaffolding a complete React app with GraphQL

Kivy: Pass Text Input Between Screens

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vihanga Malshan(it19111766)

Vihanga Malshan(it19111766)

I am a 3rd-year Software Engineering undergraduate at the Sri Lanka Institute of Information Technology- SLIIT, Reg.no : IT19111766

More from Medium

Vue.js State Managment with Vuex

How We Made Vite Run in Browser

Minimize Vulnerabilities with Serverless

Express vs Koa