Fixing typescript error: Cannot find module ‘./categories’.

If you try to import a js file you’ve written, you may get an error like this:

Cannot find module './categories'.

Doing something like this:

import * as categories from "./categories";

In this case I have a file called “categories.js”.

The easiest way to fix this is to rename the file to “categories.ts”. Otherwise, Typescript things you might need a type mapping (the other way to fix this is to add a .d.ts file for your other library, so it has a type mapping)

Leave a Reply

Your email address will not be published. Required fields are marked *