admin管理员组文章数量:1330566
I have downloaded Node.js
from their site in my windows xp os. I have installed it through the microsoft installer. I didn't know how to write my first application, where to save them and how to execute them in Windows. I have got a node.js
mand prompt but I can't use it.
I have searched a lot but there is only instruction for linux
and mac
. I didn't find any suitable tutorial
or example that I can start a node application from scratch.
If anybody can put some documentation
or steps
or any such tutorial where I can get help of this, it will be great for me.
I have downloaded Node.js
from their site in my windows xp os. I have installed it through the microsoft installer. I didn't know how to write my first application, where to save them and how to execute them in Windows. I have got a node.js
mand prompt but I can't use it.
I have searched a lot but there is only instruction for linux
and mac
. I didn't find any suitable tutorial
or example that I can start a node application from scratch.
If anybody can put some documentation
or steps
or any such tutorial where I can get help of this, it will be great for me.
- 1 I imagine if you have a node.js mand prompt then it would be as simple as creating a js based file in a directory, then navigating to that directory using the node.js mand prompt and then typing node <your_script_name>. – Simon H Commented Dec 13, 2012 at 7:04
- ok I am trying it @ZeSimon – Mrinmoy Ghoshal Commented Dec 13, 2012 at 7:05
-
1
If you search Google exactly for
node.js server windows
, there's several articles on how to run it with a server. Note, however, that most of what I saw reference IIS, which I have no idea if and how you can get that installed. But you need a server running that can handle sending requests to your node.js runtime. Apache, nginx, lighthttp, and IIS are most typical (Tomcat?). – Jared Farrish Commented Dec 13, 2012 at 7:12 - Here's a tutorial, using node.js to create a server. Seems interesting. – Jared Farrish Commented Dec 13, 2012 at 7:14
2 Answers
Reset to default 8As this blog entry by Eric, it is ridiculously easy to get a node.js server setup and responding to requests on 127.0.0.1:#port#
.
Really easy. I just did it all in... Longer than write this text.
Download an OS-appropriate node.js1: http://nodejs/
Now, create a
.txt
(plaintext) file in the same folder as yournode.exe
and rename that toserver.js
.Put this Javascript in that file:
var http = require('http'); http.createServer(function (request, response) { console.log('request starting...'); response.writeHead(200, { 'Content-Type': 'text/html' }); var html = '<p>Hello World!</p>'; response.end(html, 'utf-8'); }).listen(8125); console.log('Server running at http://127.0.0.1:8125/');
Open a
cmd.exe
andcd c:\path\to\the\node\executable
, wherenode.exe
resides.From there, run:
node server.js
You should see it say:
Server running at http://127.0.0.1:8125
Open a browser and put
http://127.0.0.1:8125/
in the address bar.You should see it say:
Hello World!
That's it. That's pretty easy. The proverbial Hello World!
in 15 seconds or less. Now how to get it to parse a Javascript file and return that output instead of simple HTML...
1. Note, I got the executable, node.exe
, made a folder somewhere, put the executable in that folder. No installer. Works like a charm.
Here is the new way develop node.js app with Windows Environments and Visual Studio >= 2012 https://nodejstools.codeplex./
本文标签: javascriptHow to write first application in Nodejs in Windows EnvironmentStack Overflow
版权声明:本文标题:javascript - How to write first application in Node.js in Windows Environment? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742258531a2442077.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论