[英]Hapi js - makemehapi Issue
Hi New Node and I am practising tutorial "makemehapi" In the third assignment I have receiving below error. 嗨,New Node,我正在练习教程“ makemehapi”。在第三份作业中,我收到以下错误。 Any one can point where I am doing wrong?
谁能指出我做错了什么?
Regards, Surya 问候,苏里亚
------------ Code --------------------- ------------代码---------------------
var Path = require('path');
var Hapi = require('hapi');
var Inert = require('inert');
var server = new Hapi.Server();
server.connection({
host: 'localhost',
port: Number(process.argv[2]|| 8080)
});
server.register(require(Inert),function(err){
if(err) throw err;
} )
server.route({
method:'GET',
path:"/index.html",
handler: {
file: "index.html"
}
})
server.start(function () {
console.log('Server running at:', server.info.uri);
});
---------------------- error-------------------------- ----------------------错误--------------------------
assert.js:86 throw new assert.AssertionError({ ^ AssertionError: path must be a string at Module.require (module.js:364:3) at require (module.js:384:17)`enter code here` at Object.<anonymous> (/home/surya/Desktop/nodeschool/Hapi Practice/test/Lesson3.js:13:17) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3 ✗ Error connecting to http://localhost:18384: ECONNREFUSED events.js:85 throw er; // Unhandled 'error' event ^ Error: connect ECONNREFUSED at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
You are requiring in Inert
twice. 您需要两次
Inert
。 Remove the require
around the Inert
variable in the following line: 在以下行中删除
Inert
变量周围的require
:
server.register(require(Inert),function(err){
if(err) throw err;
});
To: 至:
server.register(Inert,function(err){
if(err) throw err;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.