0

I tried to launch a simplest app, described here: https://community.c9.io/t/writing-a-node-js-app/1731 The single file (server-cloud9.js) I try to launch contains the following code:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(process.env.PORT, process.env.IP);

The command saved in the config is, accordingly:

node server-cloud9.js

But after calling the Run command I got following message:

Your code is running at https://js-world-srgg6701.c9users.io.
Important: use process.env.PORT as the port and process.env.IP as the host in your scripts!

module.js:327
throw err;
^

Error: Cannot find module '/home/ubuntu/workspace/node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

Process exited with code: 1

Why?

Paul
  • 35,689
  • 11
  • 93
  • 122
srgg6701
  • 1,878
  • 6
  • 23
  • 37

1 Answers1

0

you need to run it from the User Interface, by clicking the green play button:

  1. Select your file, in your case it's server-cloud9.js
  2. Click the green play button in the upper side of the UI.

And magic is done.

Soldeplata Saketos
  • 3,212
  • 1
  • 25
  • 38