如何修复内部服务器错误?-Google Cloud [英] How do I fix an Internal Server Error?- Google Cloud

查看:139
本文介绍了如何修复内部服务器错误?-Google Cloud的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google Cloud Platform上跟踪本教程,发现SIMPLE应用程序已成功在端口8080上启动,但是当我转到浏览器进行外部查看时,出现内部服务器错误.该教程可以在这里找到: https://cloud.google.com/appengine/docs/standard/nodejs/building-app/deploying-web-service 我正在使用GCP云外壳终端使用Win8.1.

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.

我也尝试过更新我的npm软件包,将yaml,nodejs文件移动到下一个更高的目录,以及删除下一个更高的目录中的package.json.就像我说的那样,端口8080可以启动并登录到终端,但在浏览器中却没有启动.我的package.json如下:

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": ""
}

我的app.yaml文件是

My app.yaml file is

runtime: nodejs10

我的server.js文件是

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}...`);
});

由于我是Google云的新手,所以任何帮助都将非常有用.同样有趣的是,express的最新版本安装在下一个更高的文件夹中,而不安装在所需JSON所在的当前文件夹中. (并且无法更新)谢谢. -MP

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

推荐答案

这似乎是因为package.json中没有明确的依赖关系:

It seems that this is because there is no express dependency in package.json:

"dependencies": {
    "express": "^4.17.1"
  }

我已经复制了所有步骤,并且一切正常.在本教程中,有4.16.3版本,我有所不同,因为我使用了npm install express -s,它会自动将版本添加到package.json中.但是它对我而言也适用于4.16.3.

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!

这篇关于如何修复内部服务器错误?-Google Cloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆