【发布时间】:2023-03-02 23:19:01
【问题描述】:
我正在尝试在 Google App Engine 上部署使用 create-react-app 创建的应用。
我的应用在本地运行良好(npm start 和 npm run build & serve -s build)。
但是,Google App Engine 上部署的应用只显示 index.html,并没有调用我的 react 代码。
Chrome 开发者控制台显示Uncaught SyntaxError: Unexpected token <。
另外,我在 console.cloud.google.com 上发现部署的应用程序不包含构建文件夹。这是正确的吗?
谁能解决这个问题?
这是我的 package.json:
{
"name": "XXXXX",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-ga": "^2.5.7",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
另外,这是我的 app.yaml。
runtime: nodejs10
handlers:
- url: /.*
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
【问题讨论】:
-
你在部署之前做了 npm run build 吗?
-
我做了,但没用...
标签: node.js reactjs google-app-engine google-cloud-platform create-react-app