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).
The tool can be found here: https://github.com/lu4/hcitool-reader
The tool is expected to be run using ts-node
(ts-node allows running TypeScript code on the fly).
My package works fine when installed globally from a local disk using following command:
bash> npm i -g /path/to/local/disk/hcitool-reader/repository
The tool can be validated (after it is installed) by executing:
bash> hcitool-reader
However if I remove old version and install the same code from NPM:
bash> npm uninstall -g hcitool-reader && npm i -g hcitool-reader
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).
bash> 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.<computed> [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.<anonymous> (/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)
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:
/home/pi/.config/versions/node/v12.8.0/lib/node_modules/hcitool-reader
in all other cases, from all other locations the code works fine.
Q: What's wrong with ts-node?
EDIT
It seems to me that it is a ts-node
issue I've created an issue in their repo, waiting for some comments from ts-node
team