我希望将使用create-react-app创建的应用程序部署到Google App Engine。
我的应用程序在本地上运行良好(包括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