Typescript build passing locally but failing on CircleCi (TS2307)
I often tell my teams that the complexity of a bug is sometimes inversely proportionate to the time spent debugging it, in other words, the simplest issues (such as typos) can be the hardest to spot. I’m writing this very short article in the hope it will be useful to some facing the exact same situation.
I had a very good example of it on Saturday, I was pushing some recent changes for a new version of ZenCrepes’ indexer (replacing github-indexer, adding features to pull data from Jira, thus the need for a new name), but my build (which was working fine a few days ago) kept failing on CircleCi while all was fine locally.
I was getting the following error on the workflow job:
src/commands/gRepos.ts:18:29 — error TS2307: Cannot find module ‘../utils/github/FetchNodesbyIds’
I first tried simple changes to tsconfig.json, without success.
Then, I ssh'd into the CircleCi’s job (Select your job, then click on “Rerun Job with SSH”) to see if I could spot any differences. Nodes and Typescript were on a different version, so I updated my local machine to see if I could get it to fail there. Without success…
Finally, the solution was, as alluded initially, super simple, I had a case issue in my import, the folder is called “FetchNodesByIds”, not “FetchNodesbyIds”. That simple b instead of B was the only source of the issue.
The reason behind the failure is that macOS filesystem is case insensitive while GNU/Linux is not. I was developing on a mac, and CircleCi jobs are running in GNU/Linux containers.