Error: File Name Casing Mismatch in TypeScript Build on Netlify

I encountered an issue during the build. I checked all the imports three times, and everything matches. There are no discrepancies. Everything is built locally. I also cleared the cache, but nothing helps. Locally, my file is called β€˜client/src/API/apiSlice.ts’.

Tried to use both api/apiSlice.ts and API/apiSlice and nothing helps, all the same.

Everything was fine before, but this error appeared when I integrated TypeScript into my project.

Netlify site name: https://chernetskyi-notes-taking-app.netlify.app/

12:39:35 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
12:39:30 PM: Netlify Build
12:39:30 PM: ────────────────────────────────────────────────────────────────
12:39:30 PM: ​
12:39:30 PM: ❯ Version
12:39:30 PM: @netlify/build 29.15.1
12:39:30 PM: ​
12:39:30 PM: ❯ Flags
12:39:30 PM: baseRelDir: true
12:39:30 PM: buildId: 64a68bc0a5eae9000802228d
12:39:30 PM: deployId: 64a68bc0a5eae9000802228f
12:39:30 PM: ​
12:39:30 PM: ❯ Current directory
12:39:30 PM: /opt/build/repo/client
12:39:30 PM: ​
12:39:30 PM: ❯ Config file
12:39:30 PM: /opt/build/repo/client/netlify.toml
12:39:30 PM: ​
12:39:30 PM: ❯ Context
12:39:30 PM: production
12:39:30 PM: ​
12:39:30 PM: Build command from Netlify app
12:39:30 PM: ────────────────────────────────────────────────────────────────
12:39:30 PM: ​
12:39:30 PM: $ npm run build
12:39:30 PM: > notes-app@0.0.0 build
12:39:30 PM: > tsc && vite build
12:39:33 PM: src/store/store.ts(17,32): error TS1261: Already included file name β€˜/opt/build/repo/client/src/API/apiSlice.ts’ differs from file name β€˜/opt/build/repo/client/src/api/apiSlice.ts’ only in casing.
12:39:33 PM: The file is in the program because:
12:39:33 PM: Imported via …/API/apiSlice from file β€˜/opt/build/repo/client/src/store/store.ts’
12:39:33 PM: Imported via …/…/…/API/apiSlice from file β€˜/opt/build/repo/client/src/store/features/auth/authApiSlice.ts’
12:39:33 PM: Imported via …/…/…/API/apiSlice from file β€˜/opt/build/repo/client/src/store/features/accountSettings/accountSetingsApiSlice.ts’
12:39:33 PM: Imported via …/…/…/API/apiSlice from file β€˜/opt/build/repo/client/src/store/features/notes/notesApiSlice.ts’
12:39:33 PM: Matched by include pattern β€˜src’ in β€˜/opt/build/repo/client/tsconfig.json’
12:39:33 PM: Matched by include pattern β€˜src’ in β€˜/opt/build/repo/client/tsconfig.json’
12:39:33 PM: ​
12:39:33 PM: build.command failed
12:39:33 PM: ────────────────────────────────────────────────────────────────
12:39:33 PM: ​
12:39:33 PM: Error message
12:39:33 PM: Command failed with exit code 2: npm run build (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
12:39:33 PM: ​
12:39:33 PM: Error location
12:39:33 PM: In Build command from Netlify app:
12:39:33 PM: npm run build
12:39:33 PM: ​
12:39:33 PM: Resolved config
12:39:33 PM: build:
12:39:33 PM: base: /opt/build/repo/client
12:39:33 PM: command: npm run build
12:39:33 PM: commandOrigin: ui
12:39:33 PM: environment:
12:39:33 PM: - VITE_API_BASE_URL
12:39:33 PM: - VITE_API_PROJECTS_URL
12:39:33 PM: - VITE_APP_CURR_MODE
12:39:33 PM: - VITE_APP_SITE_KEY
12:39:33 PM: publish: /opt/build/repo/client/dist
12:39:33 PM: publishOrigin: ui
12:39:33 PM: redirects:
12:39:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:39:35 PM: Failing build: Failed to build site
12:39:36 PM: Finished processing build request in 20.678s

@dimitrij Check src/store/store.ts on line 17.

The error seems to indicate that you’re importing src/API/apiSlice.ts in one spot and src/api/apiSlice.ts in another spot.

@nathanmartin That’s the thing, that I import it everywhere precisely as src/api/apiSlice.ts and it makes me confused. :melting_face:

@dimitrij Were you able to spot where it was?

@nathanmartin It was actually a problem with Git, somehow 1 more API folder was created on the remote repository, and only the api was displayed locally, the problem was solved after manually deleting the API folder on GitHub. It turned out that I was looking for an error in the wrong place.

1 Like

thanks for sharing your solution with the community.

1 Like