title: Why can't my globally installed npm package call ts-node?
body: <p>Ok, I'm trying to create a CLI tool for my own use, basically it just parses standard output of hcitool (which reports on surrounding bluetooth devices).</p>
  
  <p>The tool can be found here: <a href="https://github.com/lu4/hcitool-reader" rel="nofollow noreferrer">https://github.com/lu4/hcitool-reader</a></p>
  
  <p>The tool is expected to be run using <code>ts-node</code> (ts-node allows running TypeScript code on the fly).</p>
  
  <p>My package works fine when installed globally from a local disk using following command:</p>
  
  <pre><code>bash&gt; npm i -g /path/to/local/disk/hcitool-reader/repository
  </code></pre>
  
  <p>The tool can be validated (after it is installed) by executing:</p>
  
  <pre><code>bash&gt; hcitool-reader
  </code></pre>
  
  <p>However if I remove old version and install the same code from NPM:</p>
  
  <pre><code>bash&gt; npm uninstall -g hcitool-reader &amp;&amp; npm i -g hcitool-reader
  </code></pre>
  
  <p>The package starts throwing node.js syntax exceptions pointing out that typescript syntax is wrong (which is a sign that ts-node wasn't registered properly). </p>
  
  <pre><code>bash&gt; hcitool-reader
  
  Trying to register ts-node with tsconfig.json found at:
  /home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader/tsconfig.json
  /home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader/src/index.ts:1
  import 'reflect-metadata';
         ^^^^^^^^^^^^^^^^^^
  
  SyntaxError: Unexpected string
      at Module._compile (internal/modules/cjs/loader.js:811:22)
      at Module._extensions..js (internal/modules/cjs/loader.js:879:10)
      at Object.require.extensions.&lt;computed&gt; [as .ts] (/home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader/node_modules/ts-node/src/index.ts:465:14)
      at Module.load (internal/modules/cjs/loader.js:731:32)
      at Function.Module._load (internal/modules/cjs/loader.js:644:12)
      at Module.require (internal/modules/cjs/loader.js:771:19)
      at require (internal/modules/cjs/helpers.js:68:18)
      at Object.&lt;anonymous&gt; (/home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader/bootstrap.js:15:20)
      at Module._compile (internal/modules/cjs/loader.js:868:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
  </code></pre>
  
  <p>The weird thing about this error is that the code stops working only when it is located NPM's global package folder, in my case:</p>
  
  <p><code>/home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader</code></p>
  
  <p>in all other cases, from all other locations the code works fine.</p>
  
  <p><strong>Q:</strong> What's wrong with ts-node?</p>
  
  <p><strong>EDIT</strong>
  It seems to me that it is a <code>ts-node</code> issue I've <a href="https://github.com/TypeStrong/ts-node/issues/874" rel="nofollow noreferrer">created an issue in their repo</a>, waiting for some comments from <code>ts-node</code> team</p>