Typescript import path case sensitivity

Typescript import path case sensitivity

Almost all developers here are Mac users 😁. Generally, by default, Mac OS file system is case insensitive.

Hence, the following line in a Typescsript file,
import { switchMap } from 'rxjs/Operators/switchMap';
would not throw any error if you build the Angular project with command ng build --prod on Mac OS.

But if you run the same project on Linux, it is likely to throw the following error,
error TS2307: Cannot find module 'rxjs/Operators/switchMap'

O in Operators in the above import statement should be in small case.

A valid import statement would be,
import { switchMap } from 'rxjs/operators/switchMap';

Hence, we need to take care while mannually importing module or file in .ts file.
We can check for such errors with help of a Docker. In our projects (almost all), we have Dockerfile in the Angular project which runs it on Nginx server inside the Docker container. If you do not have such a Dockerfile then you can create one if possible.

Then, you just need to build that Dockerfile with docker build ./ (considering said Dockerfile is in the current directory) and the output log will show you these errors if they are present.