Search code examples
node.jsexpresstessel

Express app cannot find index.html


I'm having a problem with my Express app when I push it to my Tessel 2, I'm able to get this working locally but once it's pushed onto another system it causes problems. This is the error I'm getting:

Error: ENOENT: no such file or directory, stat '/tmp/remote-script/public/index.html'
    at Error (native)

And this is my Express route setup:

app.use('/static', express.static('public'))

app.get('/', function (req, res) {
  res.sendFile(path.join(__dirname + '/public/index.html'));
})

I've tried several different file path locations such as /../public/index.html and none of them seem to work. My directory structure has index.js as the primary node file, and then I have a public directory with the index.html file within it.

Any help would be greatly appreciated.


Solution

  • This ended up being an issue with the Tessel 2 not Node, I needed to update the .tesselinclude file to push the public directory to the device, like so: public/**