简体   繁体   English

无法让Node.js Express代码在Cloud 9中说出“Hello World”

[英]Can't get Node.js Express code to say 'Hello World' in Cloud 9

Been experimenting with Cloud 9 and have been trying to use the example code from the Express website in order to get 'Hello World!'. 一直在尝试使用Cloud 9,并且一直在尝试使用Express网站上的示例代码来获得“Hello World!”。 I tried listening to several different ports/ip referring to https://docs.c9.io/docs/run-an-application and Running Hello World using Node js Express in cloud 9IDE . 我尝试使用 https://docs.c9.io/docs/run-an-application在云端9IDE中使用Node js Express运行Hello World,试听几个不同的端口/ ip。 Although the listener will run, it will never close or return anything after that. 虽然监听器将运行,但在此之后它将永远不会关闭或返回任何内容。 Does anyone know why this may be? 有谁知道为什么会这样? Here's my code: 这是我的代码:

var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('Hello World!');
});

app.listen(process.env.PORT, process.env.IP, function(){
    console.log('LISTENING');
});

You should run the app.js from the c9 command, which is just below, in the editor. 您应该在编辑器中从c9命令运行app.js ,该命令就在下面。 Cloud9 has it's own default path to run. Cloud9有自己的默认路径来运行。 Default like something : 默认喜欢的东西:

https://helloexpress-abcd.c9.io/ https://helloexpress-abcd.c9.io/

helloexpress is the project name you defined, in your case it's different, helloexpress是您定义的项目名称,在您的情况下它是不同的,

abcd is the username and the rest are the defaults abcd是用户名, 其余是默认值

This should show Hello World 这应该显示Hello World

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM