Node / connect issue Object function createServer has no method static [duplicate]

∥☆過路亽.° 提交于 2019-11-27 03:04:43

问题


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!


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!