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

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

  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


// 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