robbie-cahill / tunnelmole-client

Tunnelmole - Connect to local servers from anywhere
MIT License
1.29k stars 80 forks source link

Using tmole as globally installed package #5

Closed Salmon42 closed 1 year ago

Salmon42 commented 1 year ago

Hello, I have tried installing tunnelmole client as a global package (like this). After trying to execute the tool, I got the following error:

> tmole 3000

node:fs:585
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open 'D:\/package.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at file:///D:/Programs/Development/NodeVersionManager/v16.16.0/node_modules/tunnelmole/dist/src/node/packageJson.js:3:35
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'D:\\/package.json'
}

I am using Windows 10, and ran the script from a Windows PS terminal while I was in a random folder (root of my secondary drive). It seems like the tmole client expects the existence of package.json in a directory where it is being run.

(source)

const { name, version } = packageJson;

program
    .name(name)
    .usage(...)
    ...

Why does it require the existence of the JSON file? Or is this unintended and should extract name and version from the package.json located in the tunnelmole/dist?

Thanks for clarification!

robbie-cahill commented 1 year ago

Thanks for reporting, this is fixed in the latest 2.1.3 release which I just published to NPM.

I'll have to find some other way to automate bumping the version numbers. There is a constant which was supposed to resolve to the root folder where tunnelmole is installed, but it looks like it doesn't work with a global npm install.

https://github.com/robbie-cahill/tunnelmole-client/commit/7bd4016c791dc118e1cb9e490e4856ae4ed37329