I am following this tutorial on Google Cloud Platform and am finding that the SIMPLE app launches successfully up on port 8080 but when I head over to the browser to view it externally, I get an internal server error. The tutorial can be found here: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/deploying-web-service I am using Win8.1 using the GCP cloud shell terminal.
I have also tried updating my npm packages, moving my yaml, nodejs files to the next higher directory as well as deleting the package.json in the next higher directory. Like I said, port 8080 can come up and logged to the terminal, but does not come up in the browser. My package.json is as follows:
{
"name": "express",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": ""
}
My app.yaml file is
runtime: nodejs10
And my server.js file is
//this is a test by MP2
// date of use : 2020-0601
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello from App Engine!');
});
// Listen to the App Engine-specified port, or 8080 otherwise
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}...`);
});
Any help would be great since I am new to the google cloud. What is also interesting is that the most current version of express is installed at the next higher folder but not in the current one where the desired JSON is. ( and unable to update it) Thank you. -MP
It seems that this is because there is no express dependency in package.json
:
"dependencies": {
"express": "^4.17.1"
}
I have replicated all steps and it worked. In the tutorial there is 4.16.3 version, I have different, because I have used npm install express -s
and it added version automatically to package.json. However it works with 4.16.3 as well on my side.
I hope it will help!