简体   繁体   中英

Static File Loader Issues: Inert and Hapi.js

I am receiving errors with my server configuration. This is a simple application which is why I do not understand why the code is failing. Please note, I have tried the methods from Hapi.js and Inert npm documentation. Hopefully, someone can provide some insight. -- Thanks

Here is my app.js

const Hapi = require('hapi');

const server = new Hapi.Server();

server.connection({
 port: 8080,
 host: 'localhost'
});


server.register({
   register: require('inert')
}, (err) => {
  if (err) {
    throw err
  }

  server.route({
    method: 'GET',
    path: '/index',
    handler: (request, reply) => {
     reply.file('./public/index.html');
   }
})

 server.start(err => {
    if (err){
      throw err;
    }
    console.log(`Server started at: ${server.info.uri}`);
  });
})

在此处输入图片说明

Had the same problem, what version are you using of node? Updating to 8.9.1 LTS solved the problem for me. I believe i read someplace that async etc is only available for version >=7.6 if I'm not mistaken.

Thanks to @Filip S for the response. Here is the suggested solution from github issues board:

"hapi v17 requires node v8 and inert v5. hapi v16 requires inert v4.

Walmart is in the middle of moving the entire ecosystem to hapi v17 and async/await. You cannot run hapi v17 or inert v5 without node 8."

Happy coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM