节点/连接问题对象函数createServer没有静态方法 [英] Node / connect issue Object function createServer has no method static

查看:147
本文介绍了节点/连接问题对象函数createServer没有静态方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AngularJS书籍(server.js)中的示例启动我的节点服务器。

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);

最初我得到对象没有方法静态所以我重新安装了connect include现在当我这样做:node server.js我在CMD(Windows)中获得了一个闪烁的光标,并且从我的浏览器中获得了无法获取/。

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.

任何想法的人?

谢谢!

推荐答案

您的应用程序运行正常。您只需要在URL中指定要从静态文件夹访问的文件的名称。例如,如果您有一个名为 app.html 的文件,则需要通过以下方式访问该文件:

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

请注意,如果你只是使用root URL,它将导致connect查找默认文件名,默认为 index.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"});

这篇关于节点/连接问题对象函数createServer没有静态方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆