tsc throws `TS2307: Cannot find module` for a local file

@vladima replied to this issue on GitHub:

The way the compiler resolves modules is controlled by
moduleResolution option that can be either node or classic (more
details and differences can be found here). If this setting is omitted
the compiler treats this setting to be node if module is commonjs and
classic – otherwise. In your case if you want classic module
resolution strategy to be used with commonjs modules – you need to set
it explicitly by using

{
    "compilerOptions": {
        "moduleResolution": "node"
    }
}

Leave a Comment