Closed joshboyan closed 7 years ago
I just performed a test clone & deploy as directed in the README from master. It deployed successfully.
So, what is going on with your setup? Something has been committed or set that is causing this…
I see that some of the node modules cache directives have been removed, but the NODE_MODULES_CACHE=true
is still set during compile. Not sure if that effects this problem.
Regarding moving react-scripts
to dependencies, I agree that would probably fix it, but I see in react-ui/package.json
that react-scripts is still in devDependencies
.
…continuing to think about this issue:
I see that npm 5's new package-lock.json
file is present. Perhaps the npm install --only-dev
trick used in heroku-postbuild
no longer works as intended with npm 5.
I'll investigate further.
Confirmed, I can now reproduce by committing npm 5's package-lock.json
:
remote: > react-ui@0.1.0 build /tmp/build_422e8ad9ada1b9f372cc9fc82eb8ade0/react-ui
remote: > react-scripts build
remote:
remote: sh: 1: react-scripts: not found
I've opened PR with a fix https://github.com/mars/heroku-cra-node/pull/10
The solution is to replace the package.json
"heroku-postbuild"
entry with:
"cd react-ui/ && npm install --only=dev && NODE_ENV=development npm install --no-shrinkwrap && npm run build"
Here's the change in context.
…originally proposed solution is just as valid:
Move react-scripts
to dependencies
in react-ui/
package, instead of devDependencies
.
OK. So I am not getting that warning anymore and the build is successful, compressed and released.
But... When I open the app I get an application error page. I am not getting any error messages form the build log and only a 503 in the console on the page.
I have ran npm start
and npm build
locally and run as expected with no errors.
I also tested deploying with and without the node module cache directives. I have kept the rest of the configuration as you prescribed in the readme and only added some modules for the API I am using.
Do you have any suggestions on how to proceed?
To diagnose a 503, which typically means that the web process is crashing, run:
heroku restart && heroku logs -t
What does it output as the web process starts up and then as you make requests to the app?
That was the nudge I needed. The remaining issues had to do with my configuration but I fixed them using the messages from heroku log
. Now everything is resolved and working as expected. Thanks for the help @mars!
Excellent @joshboyan 🥂
I am having a difficult time getting this deployed once I add some more code to the repo.
It works just as expected locally with the
npm run start
andnpm run build
commands.I have been searching stack overflow and haven't found anything. I have even tried to add react-scripts to the Dependencies as well but am still getting this print out when I deploy.
I found that if I set
NPM_CONFIG_PRODUCTION=false
it compiles without any errors and deploys but I just get a 503 error when I check the site.Also, while troubleshooting this I ran the heroku post-build hook
cd react-ui/ && npm install --only=dev && npm install && npm run build
locally from the parent directory and got this message.If the rest of the source would help you can see it here