My this app, is working perfectly in local machine with localhost . But faililng to deploy in Google App Engine. I have tried quite a few trials with the app.yaml file, but just not able to deploy it successfully.
Most probably I am configurating the app.yaml file and the package.json file incorrectly.
Here's the full source code of the project
Here's the crucial part of the package.json file in the in the project root (for the server).
"scripts": {
"server": "nodemon index.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"start": "cd client && npm install && npm run build && cd .. && npm run dev",
"heroku-postbuild": "cd client && npm install && npm run build",
"fix-code": "prettier-eslint --write 'src/**/*.{js,jsx}' ",
"fix-styles": "prettier-stylelint --write 'src/**/*.{css,scss}' "
},
And inside my Client directory (which is serving my React client), I have the package.json for React
Below is my app.yaml code at the root of the project.
runtime: nodejs
env: flex
handlers:
- url: /api/.*
script: auto
- url: /
static_files: client/build/index.html
upload: client/build/index.html
- url: /
static_dir: client/build
When I finally run gcloud app deploy I get below error
**ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
> [email protected] start /app
> cd client && npm install && npm run build && cd .. && npm run dev**
> [email protected] postinstall /app/client/node_modules/jss
> node -e "console.log('\u001b[35m\u001b[1mLove JSS? You can now support us on open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/jss/donate\u001b[0m')"
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `cd client && npm install && npm run build && cd .. && npm run dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-03-31T14_50_44_347Z-debug.log
To get the log from gcloud, I run gcloud app logs tail -s default and it shows the following
2019-03-31 13:28:18 default[20190331t185321] Express Server running on port 8080
2019-03-31 13:28:19 default[20190331t185321] Connected to Database (MongoDB)
2019-03-31 13:28:19 default[20190331t185321] (node:18) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
2019-03-31 13:36:18 default[20190331t185321] ::ffff:172.17.0.4 - - [Sun, 31 Mar 2019 13:36:18 GMT] "GET / HTTP/1.1" 404 139 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"
2019-03-31 13:36:18 default[20190331t185321] ::ffff:172.17.0.4 - - [31/Mar/2019:13:36:18 +0000] "GET / HTTP/1.1" 404 139
2019-03-31 14:49:41 default[20190331t201413]
2019-03-31 14:49:41 default[20190331t201413] > [email protected] start /app
2019-03-31 14:49:41 default[20190331t201413] > cd client && npm install && npm run build && cd .. && npm run dev
2019-03-31 14:49:41 default[20190331t201413]
2019-03-31 14:49:42 default[20190331t201413]
2019-03-31 14:49:42 default[20190331t201413] > [email protected] start /app
2019-03-31 14:49:42 default[20190331t201413] > cd client && npm install && npm run build && cd .. && npm run dev
2019-03-31 14:49:42 default[20190331t201413]
2019-03-31 14:50:42 default[20190331t201413]
2019-03-31 14:50:42 default[20190331t201413] > [email protected] postinstall /app/client/node_modules/jss
2019-03-31 14:50:42 default[20190331t201413] > node -e "console.log('\u001b[35m\u001b[1mLove JSS? You can now support us on open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/jss/donate\u001b[0m')"
2019-03-31 14:50:42 default[20190331t201413]
2019-03-31 14:50:43 default[20190331t201413]
2019-03-31 14:50:43 default[20190331t201413] npm ERR! code ELIFECYCLE
2019-03-31 14:50:43 default[20190331t201413] npm ERR! errno 1
2019-03-31 14:50:43 default[20190331t201413] npm ERR! [email protected] start: `cd client && npm install && npm run build && cd .. && npm run dev`
2019-03-31 14:50:43 default[20190331t201413] npm ERR! Exit status 1
2019-03-31 14:50:43 default[20190331t201413] npm ERR!
2019-03-31 14:50:43 default[20190331t201413] npm ERR! Failed at the [email protected] start script.