[英]How to configure a Google App Engine nodejs8 Standard Environment for React app?
I have developed a simple app using React and Node.js 8 for Google App Engine. 我使用React和Node.js 8 for Google App Engine开发了一个简单的应用程序。 It works fine in the Flexible Environment, but if I try to deploy it on the Standard Environment, I am getting "GET / HTTP/1.1" 500 errors.
它在灵活环境中可以正常工作,但是如果我尝试在标准环境中部署它,则会收到“ GET / HTTP / 1.1” 500错误。 I can't find any more information on what is going wrong beyond that.
除此以外,我找不到更多有关发生问题的信息。
How can I configure it so that it will work in the standard environment? 如何配置它使其在标准环境中运行?
app.standard.yaml app.standard.yaml
runtime: nodejs8
handlers:
- url: /
script: src/index.js
- url: /src
script: index.js
package.json 的package.json
{
"name": "eventpub",
"version": "0.1.0",
"private": true,
"engines": {
"node": "8.x.x"
},
"dependencies": {
"node-pre-gyp": "^0.11.0",
"npm": "^5.6.0",
"react": "^16.4.2",
"react-collapsible": "^2.3.1",
"react-dom": "^16.4.2",
"react-json-viewer": "^1.7.1",
"react-scripts": "1.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
project folder structure 项目文件夹结构
node_modules
public
- public/index.html
- public/manifest.json
src
- src/App.css
- src/App.js
- src/App.test.js
- src/index.css
- src/index.js
- src/registerServiceWorker.js
.gcloudignore
.gitignore
app.flexible.yaml
app.standard.yaml
package.json
package-lock.json
README.md
在我看来,您遇到的问题是由于https://cloud.google.com/appengine/docs/standard/nodejs/runtime#dependencies所述的Node.js的App Engine Standard仍处于测试阶段
I solved the issue by building the react app first (npm run build), deploying the already built version to google cloud, and adding handlers for the built app in app.yaml. 我通过首先构建react应用(npm run build),将已经构建的版本部署到google cloud以及在app.yaml中添加已构建应用的处理程序来解决了该问题。
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.