node.js - Getting started with hapi.js -


i looking @ making simple hello world hapi.js tutorial.

i have installed hapi:

  1. npm init
  2. npm install hapi --save
  3. i large set of folders files

i tried doing node index.js , gave me errors. cd node_modules , got error when running node. cd again hapi , again got error when running node index.js. added of syntax tutorial.

var hapi = require('hapi');  var server = new hapi.server(); server.connection({      host: 'localhost',      port: 8000  });  // add route server.route({     method: 'get',     path:'/hello',      handler: function (request, reply) {         reply('hello world');     } });  // start server server.start(); 

not sure should running index.js

the node_modules folder used store dependencies application (ie. express, hapi, etc). similar lib (library) folder in other languages.

when download dependencies using npm install, node_modules folder placed @ root of project. source files can placed anywhere within root or within subfolders create. shouldn't however, placed in node_modules folder since meant external dependencies.

contrary other answer, you're not restricted executing program in root - can execute in subfolder well. when run program, if node can't find node_modules folder in current directory, move parent directory until finds it. see node's modules documentation.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -