我正在寻找使用hapi.js教程制作简单的Hello World。hapi.js入门
我已经安装了高致病性禽流感:
npm init
npm install hapi --save
- 我得到一个大组文件夹与文件
我想这样做node index.js
这给了我的错误。所以我cd
到node_modules
并且在运行node
时得到了另一个错误。我再次将cd
转换为hapi
,并在运行node index.js
时再次出现错误。我添加了教程中的所有语法。
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({
host: 'localhost',
port: 8000
});
// Add the route
server.route({
method: 'GET',
path:'/hello',
handler: function (request, reply) {
reply('hello world');
}
});
// Start the server
server.start();
不知道我应该在哪里index.js
错误信息请?在node_modules中运行程序不会带来任何收益 – gregnr 2015-03-31 18:01:41
好的,这很有道理。我制作了一个app.js文件,并能够让所有的东西在那里工作。但是,它位于node_modules中。当我npm安装hapi时,我得到了多个文件夹中的文件。我是否忽略这些并且为mvc创建我的通常文件夹? – Winnemucca 2015-04-01 00:06:00
是的 - 查看我的答案 – gregnr 2015-04-01 02:14:25