skistaddy
skistaddy

Reputation: 2224

ENOENT ERROR when file exists?

I'm running this Express app:

var express = require("express");
var favicon = require("serve-favicon");
var path = require("path");
var app = express();

app.use(express.static(__dirname + '/private/'));

app.get("/", function(req, res){
    res.sendFile(__dirname + "/public/index.html");
    console.log("Visited "+req.url);
});

app.get("/products", function(req, res){
    res.sendFile(path.join(__dirname, "/public/products.html"));
    console.log("Visited "+req.url);
});

app.get("/join", function(req, res) {
    res.sendFile(__dirname + "/public/join.html");
    console.log("Visited "+req.url);
});

app.get("*", function(req, res){
    res.sendFile(__dirname + "/public/404.html");
    console.log("Visited "+req.url);
});

app.listen(8080);

and am trying to go to the /products tab, and am getting this error:

Error: ENOENT: no such file or directory, stat '/home/ubuntu/workspace/public/products.html'
at Error (native)

this file exists. And as far as I can tell, I'm running everything right. So why is this happening? Is it because I'm using Cloud9 IDE? Or some other error?

Upvotes: 1

Views: 1249

Answers (1)

martriay
martriay

Reputation: 5742

Check if the user executing the program has read permission over the file.

Upvotes: 1

Related Questions