Development page blank on first load
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes
Environment
just says it's missing app name
Steps to Reproduce
It's definitely something in my project (upgraded from latest 1.x), because a brand new app works. when I first start the development servers, it has the following html:
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>
<script src="/static/js/bundle.js"></script>
<script src="/static/js/0.chunk.js"></script>
<script src="/static/js/main.chunk.js"></script>
</body>
The Page comes up blank and react-dev-tools (chrome extension) says this page is not using react
It's almost like the JS is never executed
But as soon as I refresh the page, the page works as expected with the following html served (notice chunk 0 is now chunk 1):
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>
<script src="/static/js/bundle.js"></script>
<script src="/static/js/1.chunk.js"></script>
<script src="/static/js/main.chunk.js"></script>
</body>
Expected Behavior
It should just load the right chunk the first time
Actual Behavior
It doesn't execute react on the first load
Reproducible Demo
Very confidential app. will try to bring it down to an MVP I can share. in the mean time I would love at least a direction to look in. there are absolutely zero errors in the console
Anyone have an idea on potential causes?
I actually have the very same problem also in confidential project. Did anyone discovered what is causing the issue?
I'm having the same issue and managed to track it down to a process that changes files at the same time that create-react-app boots in dev mode. If the process happens a tiny bit later, it's all good. I don't remember exactly at which point it started happening but it used to work fine in the past.
I made a tiny project that reproduces the issue https://github.com/dariocravero/cra-blank. The process is simulated by a loop in bash that touches src/App.js. Can you check if it does the same for you?
@dariocravero for me the less compiler causes this - i compile the LESS in parallel with running CRA. If i run LESS and CRA in different terminal tabs, it works fine. It worked on CRA v1.* , something must have changed internally in CRA. However since its just in development it's low priority for me to debug and fix.
@Kamahl19 I think you just nailed it. Stylus is my CSS processor of choice and it runs in parallel with CRA to generate .css files
having the same problem running node-sass. something must've changed in the compile process.
@omerdn1 almost definitely. running the same codebase and dev setup on my computer at home (much more powerful in every aspect) doesn't have this issue
i have the same issue after upgrade
Pull request to fix this problem...
https://github.com/facebook/create-react-app/pull/6215
@NilsonBF How exactly is it fixing this issue? It only changes path on Win, but this issue happens on MacOS as well
the problem consists on the built index.html wont find js and css references from static folder
u need to use a dot before the backslash on script and style import
<script src="./static/js/bundle.js"></script>
<script src="./static/js/1.chunk.js"></script>
<script src="./static/js/main.chunk.js"></script>
@NilsonBF How exactly is it fixing this issue? It only changes path on Win, but this issue happens on MacOS as well
Updated pull request for macOs solution too
I'm on Linux, using node-sass and facing the same issue. Why do we need to check the OS? Looks like it's an issue on Win, Mac and Linux as well.
this is not an OS specific issue and really should not be an OS dependent solution..
Pull Requests tests failed on ubuntu, nobody reportes on Ubuntu yet. In a couple of minutes ill test on ubuntu, then commit the edits.
Thanks ubuntu devs. :)
Updated pull request without OS dependent!
For awhile u guys can change this line in yours projects.
Tell me how its going
WE are also experiencing the same issue. Keep us updated how its going, if there's a good fix for it.
While my pull request is opened, you guys can fix your own node modules...
- node_modules
- react-script
- config
- path.js
- config
- react-script
on path.js line 45
broken => envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); fixed=> envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './');
I ve tried the @NilsonBF 's fix but not works for me,
I m concurrently running postcss cli with watch and react-scripts start on my project.
I ve tried on linux, windows, macos The issue surprisingly happens only on linux:
"scripts": {
"start": "yarn run start:tw & yarn run start:cra",
or
"scripts": {
"start": "concurrently \"yarn run start:tw\" \"yarn run start:cra\"",
it's solved with adding sleep to delay react-scripts on linux but it's not a proper solution.
"scripts": {
"start": "concurrently \"yarn run start:tw\" \"sleep 1 && yarn run start:cra\"",
or
"scripts": {
"start": "yarn run start:tw & sleep 1 && yarn run start:cra",
any workaround would be appreciated.
I think the only %100 fix is to add a flag to the cli for CRA to be able to call another script at boot. it would then be able to guarantee the second script isn't run until CRA is done booting