[英]Need help getting simple node.js express to run
I'm trying a simple sample of node express that I copied from online. 我正在尝试从网上复制的节点表示的简单示例。 The script is below which I think is pretty standard.
我认为以下脚本是非常标准的。
var http = require('http');
http.createServer(function(request, response)){
response.writeHead(200);
response.write("hello");
response.end();
}).listen(8080);
console.log('listening on port 8080...');
I used the bash on ubuntu on windows command as follows: 我在Windows命令的ubuntu上使用了bash,如下所示:
When I do this, I expect some response from the command line. 当我这样做时,我希望从命令行得到一些响应。 But when I enter the "node SamplerServer.js" command, nothing happens.
但是,当我输入“ node SamplerServer.js”命令时,什么也没有发生。 When I direct the browser to port 8080, I get an error message as well.
将浏览器定向到端口8080时,我也会收到一条错误消息。
I'm using nodeclipse and the installing that on my machine was pretty complicated. 我正在使用nodeclipse,并且在我的计算机上进行安装非常复杂。 Prior to any of the steps above, I created an express project in eclipse ide.
在执行上述任何步骤之前,我在eclipse ide中创建了一个快速项目。 It seems to perform a lot of pre steps but in the end, I think I'm getting some of the error messages below.
它似乎执行了许多准备工作,但最后,我想我收到了下面的一些错误消息。 I'm mentioning this because I'm thinking perhaps I installed one of the modules wrong.
我之所以这样说是因为我在想,也许我安装了一个错误的模块。
Start with simple stuff... 从简单的东西开始...
Use express-generator to create simple
app by the following command 通过以下命令使用express-generator创建
simple
应用程序
1-> npm install -g express-generator
with root
or Admin
access 1->具有
root
或Admin
访问权限的npm install -g express-generator
2-> Run express demoapp
. 2->运行
express demoapp
。
3-> Navigate to demoapp
3->导航到
demoapp
4-> Do npm install
4->执行
npm install
5-> Run from command with npm start
: it run by default on http://localhost:3000
5->使用
npm start
从命令npm start
:默认情况下在http://localhost:3000
Hit that URL
from Browser
从
Browser
点击该URL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.