Problem configuring Express

Posted March 4, 2018 2.1k views
Node.jsUbuntu 16.04

Hello! I am trying to configure Express on my Nginx server, but the terminal hangs on me after trying to run the script. I have a file in the same directory as my index.html (/var/www/html) called script.js that I am trying to run. Here is the code:

var express = require('express');
var app = express();
app.get('/', function (req, res) {
var server = app.listen(3000, 'MY_DROPLET_IP', function () {
  var port = server.address().port;
  console.log('Example app listening at port %s', port);
module.exports = server;

When I type node script.js, “example app listening” and all that jazz comes up in the terminal, but then I can’t type anything else, and going to MYDROPLETIP:3000 does not display anything except a Chrome error page. Please help!

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

This question was answered by @joshcamachofl:

Hi everyone:

I fixed it using this guide.

Thank you!

View the original comment