This question already has an answer here:
- “Cannot GET /” with Connect on Node.js 10 answers
I'm trying to launch my node server using an example from an AngularJS book (server.js).
var connect = require('connect');
connect.createServer(
connect.static("../angularjs")
).listen(5000);
Initially I was getting "object has no method static" so I re-installed the connect include and now when I do: node server.js I get a blinking cursor in CMD (Windows) and "Cannot GET /" from my browser.
Any ideas folks?
Thanks!
Your application is working just fine. You just need to specify the name of the file you want to access from static folder in the URL. For example if you have a file called app.html
you need to access it via:
http://localhost:5000/app.html
Note that if you just use root URL, it will cause connect to look for default file name, which defaults to index.html
. You can change that by passing new default file name in options:
connect.static("../angularjs", {default: "app.html"});
来源:https://stackoverflow.com/questions/23978734/node-connect-issue-object-function-createserver-has-no-method-static