Setting up Hapi js Server

  1. Install node as per your operating system, through
sudo apt-get updatesudo install nodejssudo install npm
nodejs — versionnpm — version
npm init
Press ^C at any time to quit.package name: (demo)version: (1.0.0)description: Setting up Hapi Jsentry point: (index.js)test command: npm startgit repository:keywords:author: Aishalicense: (ISC)About to write to /home/user/Desktop/demo/package.json:{“name”: “demo”,“version”: “1.0.0”,“description”: “Setting up Hapi Js”,“main”: “index.js”,“scripts”: {“test”: “npm start”},“author”: “Aisha”,“license”: “ISC”}Is this OK? (yes) Y
{“name”: “Setting up Hapi js”,“version”: “1.0.0”,“description”: “Setting up Hapi Js”,“main”: “index.js”,“scripts”: {“test”: “npm start”},“author”: “Aisha”,“license”: “ISC”}
npm @hapi/hapi
{“name”: “demo”,“version”: “1.0.0”,“description”: “Setting up Hapi Js”,“main”: “index.js”,“scripts”: {“test”: “npm start”},“author”: “Aisha”,“license”: “ISC”,“dependencies”: {     “@hapi/hapi”: “²⁰.0.3”    }}
‘use strict’const hapi = require(‘@hapi/hapi’);const init = async () => {    const server = hapi.server({        port: 8000, // write your port here        host: ‘localhost’ // write your host here    });    await server.start();    console.log('Server running on %s',;};init();
node index.js
Server running on port 8000



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


Software Engineer working on backend technologies.