Make sure Git knows about case-sensitive changes to your file names

#115 · May 31, 2022 · Estimated 1 minute read

It's only peculiar if you don't understand it and for a while, I didn't understand it. It builds locally but then can't resolve component on Netlify.

It started with me migrating my blog from Gatsby 3 to 4. I had neglected my blog for months so my experience with the tools and frameworks were rusty and out of date. Eventually I got the following error on Netlify. The build worked 💯 locally.

failed Building production JavaScript and CSS bundles - 39.656s
error Generating JavaScript bundles failed
Can't resolve '../components/Layout' in '/opt/build/repo/src/pages'
If you're trying to use a package make sure that '../components/Layout' is installed. If you're trying to use a local file make sure that the path is correct.

What's different?

Eventually it dawned on me and things became clearer. Much less peculiar.

The filesystem differs!

I must've renamed the component on the filesystem and forgot to do so on Git. When Netlify pulls the repository from GitHub, the poor component has a different name. You'll need to move the file in Git in order to fix this.

git mv src/components/layout.js src/components/Layout.js