我正在尝试部署我在 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