Comment run a hello.js file dans Node.js sur windows?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment run a hello.js file dans Node.js sur windows?

Message par ForumBot »

How to run a hello.js file in Node.js on windows?




Source : Stack Overflow [windows]

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment run a hello.js file dans Node.js sur windows?

Message par ayi »

Here are the exact steps I just took to run the “Hello World” example found at http://nodejs.org/. This is a quick and dirty example. For a permanent installation you’d want to store the executable in a more reasonable place than the root directory and update your PATH to include its location.



` var http = require(‘http’);

http.createServer(function (req, res) {

res.writeHead(200, {‘Content-Type’: ‘text/plain’});

res.end(‘Hello World\n’);

}).listen(1337, “127.0.0.1”);

console.log(‘Server running at http://127.0.0.1:1337/’);



- Save the file

- Start -> Run... -> cmd

- c:

-
C:>node hello.js


Server running at http://127.0.0.1:1337/



That's it. This was done on Windows XP.
Répondre

Revenir à « Performance & Dépannage »