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

The Solution to tsc throws `TS2307: Cannot find module` for a local file is


@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"
    }
}

~ Answered on 2016-06-01 12:37:16


Most Viewed Questions: