title: Cannot find Typescript module even though tsc successfully manages to resolve it
body: <p>I have a Node.js project written in Typescript which is expected to run as a CLI, and am having trouble to import a module located out of the <code>node_modules</code> directory using an absolute path (relative paths work fine). It might be important to mention that I am using the <a href="https://github.com/oclif/oclif" rel="noreferrer">oclif framework</a> for building my CLI.</p>
  
  <p>My project is organized as follows:</p>
  
  <pre><code>cli
   |--node_modules
   |--src
       |--my-module.ts
       |--subdir
            |--index.ts
  </code></pre>
  
  <p>Within <code>my-module.ts</code> I have:</p>
  
  <pre><code> export class MyClass {
       myClassFcn(s: string) {
           return 'result'
       }
   }
  </code></pre>
  
  <p>The <code>index.ts</code> script contains something like:</p>
  
  <pre><code> import {MyClass} = require('my-module')
  </code></pre>
  
  <p>When I try to execute my app with ts-node, I get </p>
  
  <pre><code>(node:10423) [MODULE_NOT_FOUND] Error Plugin: cli: Cannot find module 'my-module'
      module: @oclif/config@1.6.17
      task: toCached
      plugin: cli
      root: /home/eschmidt/Workspace/cli
      Error Plugin: cli: Cannot find module 'my-module'
          at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
          at Function.Module._load (internal/modules/cjs/loader.js:497:25)
          at Module.require (internal/modules/cjs/loader.js:626:17)
          at require (internal/modules/cjs/helpers.js:20:18)
          at Object.&lt;anonymous&gt; (/home/eschmidt/Workspace/cli/src/commands/create/index.ts:5:1)
          at Module._compile (internal/modules/cjs/loader.js:678:30)
          at Module.m._compile (/home/eschmidt/Workspace/cli/node_modules/ts-node/src/index.ts:403:23)
          at Module._extensions..js (internal/modules/cjs/loader.js:689:10)
          at Object.require.extensions.(anonymous function) [as .ts] (/home/eschmidt/Workspace/cli/node_modules/ts-node/src/index.ts:406:12)
          at Module.load (internal/modules/cjs/loader.js:589:32)
      module: @oclif/config@1.6.17
      task: toCached
      plugin: my-plugin
      root: /home/eschmidt/Workspace/cli
  </code></pre>
  
  <p>What I can't understand is that when I run <code>tsc --traceResolution</code> the module is correctly resolved:</p>
  
  <pre><code>======== Module name 'my-module' was successfully resolved to '/home/eschmidt/Workspace/cli/src/my-module.ts'. ========
  </code></pre>
  
  <p>My <code>tsconfig.json</code> file contains:</p>
  
  <pre><code>{
    "compilerOptions": {
      "declaration": true,
      "moduleResolution": "node",
      "forceConsistentCasingInFileNames": true,
      "importHelpers": true,
      "module": "commonjs",
      "sourceMap": true,
      "outDir": "./lib",
      "pretty": true,
      "rootDirs": [
        "./src/"
      ],
      "strict": true,
      "target": "es2017",
      "baseUrl": "src"
    },
    "include": [
      "./src/**/*"
    ]
  }
  </code></pre>
  
  <p>I would greatly appreciate it if anyone could shed some light on this issue, or at least suggest where to look for further help. In case more details are needed, please let me know. </p>
  
  <p>Thanks in advance!</p>