Onur Çevik
Onur Çevik

Reputation: 1590

Modifying sample Hello World Node.js code not taking effect in Google Compute Engine

I'm trying to understand the working mechanism of Compute Engine in order to write a WebSocket in Node.js which functions in Compute Engine. In order to do that, I first started off with running(npm start) the sample Hello World project and got it working. Then, I tried changing the ".send("Hello World!")" to ".send("Hello World2!")" and ran again, but I got " Hello World!" again, even though i changed the source code. When I tried "git commit", I got "Your branch is up to date". Then after trying "git pull" followed with a "git push", I still got "Hello World!" as output. How do I modify the code and make it run the modified code?

Hello World Sample Code Provided By Google

var express = require('express');

var app = express();

// [START hello_world]
// Say hello!
app.get('/', function (req, res) {
  res.status(200).send('Hello, world!');
});
// [END hello_world]

if (module === require.main) {
  // [START server]
  // Start the server
  var server = app.listen(process.env.PORT || 8080, function () {
    var port = server.address().port;
    console.log('App listening on port %s', port);
  });
  // [END server]
}

module.exports = app;

Upvotes: 1

Views: 129

Answers (1)

Ben Marks
Ben Marks

Reputation: 46

You'll need to restart your server for changes to take effect. After you've change the code in your app.js, cancel the previous "npm start" process and call it again to run the updated server

Upvotes: 3

Related Questions