Building static HTML for pageserror: Error: ENOENT: no such file or directory
workaround 1
add 404.js
or 404.tsx
file inside pages
folder if you don't
- Try to uninstall the
build
.cache
, andnode_modules
. yarn add pkg.json
npm install *
- pass all the required props to the layout (comp) in all the pages that it was used.
- run the
gatsby develop
beforegatsby build
workaround 2
probably you're using React.lazy
suspense
in your component which doesn't support server-side render, you need to remove it by any possible way.then try this should work!
// clean gatsby cachegatsby clean// delete node modules, cache and public folder.rm -rf node_module .cache public// reinstall node modulesnpm install// run gatsby in develop modegatsby develop// build the gatsby projectnpm run build// serve the building project.gatsby serve
If the above answers don't work for you (didn't for me), Gatsby keeps a copy of a config.json here ~/.config/gatsby/config.json
.
Deleting the file made it work for me.
Relevant Github issue from the Gatsby repo