title: How to use global Node packages with Typescript
body: <p>Using global packages is possible by install them via <code>npm install -g ...</code>.<br>
  If Typescript types are installed in this way, they are also available in the global folder, for example <code>/usr/lib/node_modules</code> on a linux system.</p>
  
  <p>When transpiling a typescript source file with <em>tsc</em>, a compiler error is printed out and the transpilation fails.</p>
  
  <p><code>src/main.ts(3,26): error TS2307: Cannot find module 'express'.
  </code></p>
  
  <p>However, I would expect that either environmental variables like <code>NODE_PATH</code> or configuration settings in file <code>tsconfig.json</code> like</p>
  
  <pre><code>{
      "compilerOptions": {
          ...
          "typeRoots": [
               "/usr/lib/node_modules/@types"
          ]
       }
  }
  </code></pre>
  
  <p>could solve that problem (see also <a href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types" rel="noreferrer">Typescript Documentation</a>).</p>
  
  <p>But all these settings are ignored. Only installing types locally in the project helps.</p>
  
  <p>So my question, why are the settings in <code>tsconfig.json</code> ignored and are there any possibilities to use globally installed types packages </p>
  
  <p><a href="https://github.com/ManfredSteiner/stackovf_46946205" rel="noreferrer">Example project</a>:</p>
  
  <p>After <code>npm install</code> you can run this project with <code>npm start</code> if all other dependencies are installed globally. Only 7 packages are installed with:</p>
  
  <pre><code>"devDependencies": {
      "@types/express": "^4.0.38",
      "@types/node": "^8.0.31",
      "@types/sprintf-js": "^1.1.0"
   }
  </code></pre>
  
  <p>If I remove the local directory <code>node_modules</code> you get the errors </p>
  
  <pre><code>src/main.ts(2,25): error TS2307: Cannot find module 'sprintf-js'.
  src/main.ts(3,26): error TS2307: Cannot find module 'express'.
  </code></pre>
  
  <p>... although these packages are available in the global package folder <code>/usr/lib/node_modules</code>.</p>