node.jshttp-status-code-404tracenode.js-connect

trace logs of 404 on serving static content by nodejs


I set up a nodejs server in a file named 'server.js' as follow:

var connect = require('connect'),
serveStatic = require('serve-static'); 
var app = connect();
app.use(serveStatic(__dirname + "/angularjs"));
app.listen(1000);

I ran the code by executing command "node server.js" in cmd (windows 10).

I was be able to reach the 'app.html' file by browsing 'http://localhost:1000/app.html' but now it respond by 404 (not found) error.

I'm not sure what's changed.

How could I trace the logs of nodejs to find the problem?


Solution

  • I found the problem\solution myself: I executed the 'server.js' inside the 'angularjs' folder so there was no 'angularjs' folder beside the 'server.js' to serve, I moved the 'server.js' to parent folder beside the 'angularjs' folder and it worked correctly.

    Yet I curious about: how to trace the "connect module" and\or "serve-static module" and\or nodejs itself.