I tried to do create a new project using create-react-app
command, run it locally and then tried to deploy it in Heroku. It deployed successfully but checked the logs, I have this:
2016-09-07T14:01:16.050677+00:00 heroku[web.1]: State changed from crashed to starting
2016-09-07T14:01:17.578503+00:00 heroku[web.1]: Starting process with command `npm start`
2016-09-07T14:01:19.769763+00:00 app[web.1]:
2016-09-07T14:01:19.769784+00:00 app[web.1]: > test-react @0.1.0 start /app
2016-09-07T14:01:19.769785+00:00 app[web.1]: > react-scripts start
2016-09-07T14:01:19.774637+00:00 app[web.1]: sh: 1: react-scripts: not found
2016-09-07T14:01:19.769785+00:00 app[web.1]:
2016-09-07T14:01:19.779458+00:00 app[web.1]:
2016-09-07T14:01:19.786608+00:00 app[web.1]: npm ERR! Linux 3.13.0-93-generic
2016-09-07T14:01:19.786927+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-09-07T14:01:19.787093+00:00 app[web.1]: npm ERR! node v5.11.1
2016-09-07T14:01:19.787433+00:00 app[web.1]: npm ERR! npm v3.8.6
2016-09-07T14:01:19.787772+00:00 app[web.1]: npm ERR! file sh
2016-09-07T14:01:19.787914+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-09-07T14:01:19.788054+00:00 app[web.1]: npm ERR! errno ENOENT
2016-09-07T14:01:19.788200+00:00 app[web.1]: npm ERR! syscall spawn
2016-09-07T14:01:19.788321+00:00 app[web.1]: npm ERR! [email protected] start: `react-scripts start
2016-09-07T14:01:19.788426+00:00 app[web.1]: npm ERR! spawn ENOENT
2016-09-07T14:01:19.788545+00:00 app[web.1]: npm ERR!
2016-09-07T14:01:19.788656+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'react-scripts start'.
2016-09-07T14:01:19.788772+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-09-07T14:01:19.788888+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the test-reactt package,
2016-09-07T14:01:19.788995+00:00 app[web.1]: npm ERR! not with npm itself.
2016-09-07T14:01:19.789127+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-09-07T14:01:19.789232+00:00 app[web.1]: npm ERR! react-scripts start
2016-09-07T14:01:19.789337+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-09-07T14:01:19.789549+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-09-07T14:01:19.789439+00:00 app[web.1]: npm ERR! npm bugs test-react
2016-09-07T14:01:19.789796+00:00 app[web.1]: npm ERR! npm owner ls test-react
2016-09-07T14:01:19.789904+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-09-07T14:01:19.793428+00:00 app[web.1]:
2016-09-07T14:01:19.793591+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-09-07T14:01:19.793697+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-09-07T14:01:19.873148+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-07T14:01:19.843679+00:00 heroku[web.1]: Process exited with status 1
2016-09-07T14:08:04.108492+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=rr-testapp.herokuapp.com request_id=6eb519a0-0588-441c-996e-c1154cce6328 fwd="31.52.138.187" dyno= connect= service= status=503 bytes=
2016-09-07T14:08:04.796327+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=rr-testapp.herokuapp.com request_id=af92039b-1227-4ce1-888a-cef4a2e0bbd8 fwd="31.52.138.187" dyno= connect= service= status=503 bytes=
From the log it looks like Heroku is trying to start the development server using npm start
. The development server in create-react-app should only be used for locally for development. For production, the app should be built with npm run build
and then the resulting bundled files served from a web server.
Are you using the Heroku Buildpack for Create React App or some other configuration? The Buildpack for Create React App builds the app and then serves the files as static assets, which is the recommended way to deploy to Heroku. You can find instructions for using this buildpack in Deploying React with Zero Configuration.
Going to close as there is not enough information here to help.
same problem when application creates new file on runtime
Most helpful comment
From the log it looks like Heroku is trying to start the development server using
npm start
. The development server in create-react-app should only be used for locally for development. For production, the app should be built withnpm run build
and then the resulting bundled files served from a web server.Are you using the Heroku Buildpack for Create React App or some other configuration? The Buildpack for Create React App builds the app and then serves the files as static assets, which is the recommended way to deploy to Heroku. You can find instructions for using this buildpack in Deploying React with Zero Configuration.