How do I fix an Internal Server Error?- Google Cloud

十年热恋 提交于 2020-06-17 13:06:36

问题


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


回答1:


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!



来源:https://stackoverflow.com/questions/62138278/how-do-i-fix-an-internal-server-error-google-cloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!