node.js js file where?

0 favourites
  • 7 posts
From the Asset Store
Source File, music and art pack for Android Negotiator
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Please someone know it?

  • 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 127.0.0.1/');

    ---

    It should write the message once you start your server.

    Cheers!

  • thanks, but it still wont work, my file is as simple as this now:

    console.log("Hello World");

    console.log('Server running at 127.0.0.1/');

    and still just ...

    i tried it the was you wrote, still just ...

  • 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.

  • 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.

  • Ashley, i know, but i use zack0wack0�s 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)