【发布时间】:2018-01-11 16:42:09
【问题描述】:
我正在研究使用 hapi.js 教程制作一个简单的 hello world。
我已经安装了 hapi:
npm initnpm 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 中运行程序不会为您带来任何好处
-
好的,这很有道理。我制作了一个 app.js 文件,并且能够让一切在那里工作。但是,它在 node_modules 中。当我 npm install hapi 我得到多个文件,其中包含文件夹。我是否忽略这些并着手为 mvc 创建我常用的文件夹?