Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ENOENT: no such file or directory in Gatsby

I've started learning Gatsby, every time I make any changes in src/pages folder, it gives an error that comes from .cache folder like this: Generating development JavaScript bundle failed

ENOENT: no such file or directory, open '...\Gatsby\src\pages\someFile.js'

I am deleting .cache folder then re-running gatsby develop command and it works, but it takes more time.

Question: Is there any command to make it faster or easier?

like image 611
Qodirbek Berdiyev Avatar asked Oct 22 '25 04:10

Qodirbek Berdiyev


1 Answers

Question: Is there any command to make it faster or easier?

gatsby clean does the trick. It removes the .cache and the /public folders. From Gatsby's docs:

At the root of a Gatsby site, wipe out the cache (.cache folder) and public directories:

gatsby clean

This is useful as a last resort when your local project seems to have issues or content does not seem to be refreshing. Issues this may fix commonly include:

  • Stale data, e.g. this file/resource/etc. isn’t appearing GraphQL error, e.g. this
  • GraphQL resource should be present but is not
  • Dependency issues, e.g. invalid version, cryptic errors in console, etc.
  • Plugin issues, e.g. developing a local plugin and changes don’t seem to be taking effect

I personally add my own commands in the package.json, like:

  "scripts": {
    // other scripts
    "start": "gatsby clean && gatsby develop",
  },

So every time I need to run a gatsby develop I run yarn start or npm run start instead, executing the gatsby clean command before.

like image 53
Ferran Buireu Avatar answered Oct 23 '25 19:10

Ferran Buireu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!