Gatsby: Errors after renaming project folder

Created on 30 Jul 2018  路  7Comments  路  Source: gatsbyjs/gatsby

Description

After I renamed my project folder from she-says to she-says-sg, I keep getting errors on gatsby develop

ENOENT: no such file or directory, open '/Users/isabellachen/Developer/projects/she-says/src/templates/page.js'

Steps to reproduce

Use a gatsby v2 starter
gatsby new my-default-project https://github.com/gatsbyjs/gatsby-starter-default#v2
gatsby develop to compile the build
^c to stop the server
mv my-default-project my-project rename the project folder
gatsby develop to compile the build again

Expected result

Build should compile as normal with no errors

Actual result

Errors for all files in /pages and /templates

For example:
Error: ENOENT: no such file or directory, open '/Users/isabellachen/Developer/ projects/my-default-project/.cache/dev-404-page.js'

error There was a problem reading the file: /Users/isabellachen/Developer/projects/my-default-project/src/pages/404.js

Environment

    System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.1.0 - ~/.nvm/versions/node/v10.1.0/bin/node
    Yarn: 1.6.0 - /usr/local/bin/yarn
    npm: 6.0.1 - ~/.nvm/versions/node/v10.1.0/bin/npm
  Browsers:
    Chrome: 68.0.3440.75
    Safari: 11.1.2
  npmPackages:
    gatsby: next => 2.0.0-beta.61
    gatsby-plugin-react-helmet: next => 3.0.0-beta.4
  npmGlobalPackages:
    gatsby-cli: 1.1.58

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

help wanted bug

Most helpful comment

I'm assuming this is due to the cache directory contents still referring to the previous folder name, which no longer exists.

I ran into this not long ago, and the quick solution for me was to just delete the .cache directory and rebuild. Hope that helps!

All 7 comments

Hi @isabellachen, do the pages in pages render even if the error is thrown? Also, can you verify if this happens in Gatsby v1? or it's just in v2?

The pages render even if errors are thrown. I did the same with Gatsby v1 default starter and there were no errors. Looks like its a v2 thing?

I'm assuming this is due to the cache directory contents still referring to the previous folder name, which no longer exists.

I ran into this not long ago, and the quick solution for me was to just delete the .cache directory and rebuild. Hope that helps!

I suspect I might cause this in https://github.com/gatsbyjs/gatsby/pull/6322 where I added query changes tracking between builds but didn't add handling in case files were deleted. So I'll assign this issue to myself.

Same thing happens if you delete a file in src/pages/ for example. Restarted gatsby develop doesn't fix it. As stoutlabs mentions, current workaround is to

rm -fr .cache

@pieh created a PR at #6966 that should fix this. Would love feedback from anyone if you're able to try it out on your project?

Removing the .cache folder worked for me too. Thanks, @millette!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

totsteps picture totsteps  路  3Comments

timbrandin picture timbrandin  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

benstr picture benstr  路  3Comments

theduke picture theduke  路  3Comments