我尝试推出一个最简单的应用,如下所述:https://community.c9.io/t/writing-a-node-js-app/1731 我尝试启动的单个文件(server-cloud9.js)包含以下代码:
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);
配置中保存的命令是:
node server-cloud9.js
但在调用Run命令后,我得到以下消息:
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
为什么?
答案 0 :(得分:0)
您需要通过单击绿色播放按钮从用户界面运行它:
server-cloud9.js
魔术已经完成。