node.js js file where?

Get help using Construct 2

Post » Tue Apr 23, 2013 2:37 pm

Hello,
im trying to start a node.js server,
but i cant, when i say: node app.js
it just sais: ...
where should i place the file? No one ever said, where i should place the file.
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
23
S
9
G
7
Posts: 253
Reputation: 4,831

Post » Tue Apr 23, 2013 3:51 pm

Please someone know it?
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
23
S
9
G
7
Posts: 253
Reputation: 4,831

Post » Tue Apr 23, 2013 4:43 pm

That's actually expected behavior...

Node is waiting either for connections, or something else, depending on your code.

So, let's say your code looks like this (a simple hello world http server):
---
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');
---


It actually won't throw anything to the console, it just sits and waits for connections.

If you add a line on the end of the file:

---
console.log('Server running at http://127.0.0.1:1337/');
---

It should write the message once you start your server.

Cheers!
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Tue Apr 23, 2013 4:58 pm

thanks, but it still wont work, my file is as simple as this now:
console.log("Hello World");
console.log('Server running at http://127.0.0.1:80/');

and still just ...
i tried it the was you wrote, still just ...
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
23
S
9
G
7
Posts: 253
Reputation: 4,831

Post » Tue Apr 23, 2013 5:16 pm

ahhhh... Don't run nodejs.exe. It's just node console, you can use that to test your ideas, or learn node.

To start some .js file in node try:

Open up command line (Start -> cmd) got to the folder where your .js file is, (c:/path/to/my/file) and then try "node myfile.js" command.
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Tue Apr 23, 2013 5:58 pm

This is a forum for Construct 2 questions. If you're trying to get node.js running you should probably ask on a different forum.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Wed Apr 24, 2013 3:15 pm

@Ashley, i know, but i use zack0wack0s plugin for this, therefor i need a node.js server, so indirect its Contruct 2 question. Lets say its a greyzone ;)

@Johnny thanks, now i got it. it finally works :D
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
23
S
9
G
7
Posts: 253
Reputation: 4,831


Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, MrWhizm, Skebab, spcsmrf and 22 guests