TransWikia.com

Building static HTML for pageserror: Error: ENOENT: no such file or directory

Stack Overflow Asked by Ericgit on December 23, 2021

I’ve gatsby project which works fine and also have 404 page, but either I get the error during gatsby build or open the browser after successfully completed the build process:

Building static HTML for pageserror: Error: ENOENT: no such file or directory

if the error I didn’t get during the gatsby build time then I have to get on the browser when run gatsby serve and open browser:

Error: ENOENT: no such file or directory, stat '/project/public/404.html'

3 Answers

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

Answered by Sohan on December 23, 2021

// clean gatsby cache
gatsby clean
// delete node modules, cache and public folder.
rm -rf node_module .cache public
// reinstall node modules
npm install
// run gatsby in develop mode
gatsby develop
// build the gatsby project
npm run build
// serve the building project.
gatsby serve

Answered by Dhanuka Perera on December 23, 2021

workaround 1

add 404.js or 404.tsx file inside pages folder if you don't

  1. Try to uninstall the build .cache, and node_modules.
  2. yarn add pkg.json npm install *
  3. pass all the required props to the layout (comp) in all the pages that it was used.
  4. run the gatsby develop before gatsby 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!

Want to use React.lazy in Gatsby

Answered by Ericgit on December 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP