Open mchkl opened 4 years ago
Reproducible example?
I made a repo with the reproducible error here: Github repo
I see following error
$ react-snap
events.js:177
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open 'GreenmotiveTest/build/index.html'
Emitted 'error' event at:
at internal/fs/streams.js:123:12
at FSReqCallback.oncomplete (fs.js:137:23) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'GreenmotiveTest/build/index.html'
Indeed there is no index.thml
only index.php
🤷♀
Sorry, I put the explanation into the README but forgot to mention it. So actually I'm using wptheme-scripts in this project to make it work with wordpress and in order to make a CRA build you have to execute npm run crabuild
which will produce index.html.
crabuild is using react-scripts build
the problem is it tries to crawl 404 twice:
✅ crawled 3 out of 9 (/react-src/404.html)
⚠️ warning: page not found /react-src/404.html/
first one is /react-src/404.html
second one with slash in the end
Probably
<Link to="/">
in 404 component gets resolved to 404.html/
Hmm.. just as an experiment I deleted the import of the 404 component, the component itself and the Route component that was rendering it. Still the same error
Also just tried to create 404 component again, remove any links inside, add
do you have postbuild in your package.json and you're only running npm run build
and not npm run build; npm run postbuild
?
Now my scripts look like this:
"scripts": {
"crastart": "react-scripts start",
"crabuild": "react-scripts build",
"craeject": "react-scripts eject",
"cratest": "react-scripts test",
"build": "wptheme-scripts build",
"start": "wptheme-scripts start",
"wpbuild": "wptheme-scripts wpbuild",
"wpstart": "wptheme-scripts wpstart",
"postbuild": "react-snap"
},
If I change "build" from wptheme-scripts to react-scripts I can execute npm run build and the postbuild runs automatically following the build. But the error persists.
Hi, I'm facing a problem when trying to run npm run postbuild after npm run build. It prerenders the routes correctly at first and then creates the 404.html file and that's when I get the following error:
I've already tried to create a file and a folder named 404.html in themes/greenmotive as well as delete 202.html and 404.html from the build folder and re-running npm run postbuild. Didn't work. Still getting the same error.
Also I tried to remove the following lines from the puppeteer_utils.js from react-snap in node_modules:
After doing this I stopped getting the error but the prerender would run in loop infinitely.
I wonder if anyone had a similar problem and found a solution. I would really appreciate any help solving this problem.
Thank you in advance!