node-whois icon indicating copy to clipboard operation
node-whois copied to clipboard

Cli: TypeError: this.lookup is not a function

Open Coxxs opened this issue 3 years ago • 1 comments

OS Version: Windows 11 Build 22449 node -v: v16.6.1

C:\>whois example.com
C:\Users\win\AppData\Roaming\npm\node_modules\whois\bin.js:23
  this.lookup(yargs.argv._[0], {
       ^

TypeError: this.lookup is not a function
    at Object.<anonymous> (C:\Users\win\AppData\Roaming\npm\node_modules\whois\bin.js:23:8)
    at Object.<anonymous> (C:\Users\win\AppData\Roaming\npm\node_modules\whois\bin.js:53:4)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

Changing 2 lines in bin.js resolve the issue for me:

...
  yargs = require('yargs');

  whois = require('./index');

+ util = require('util');

  yargs.usage('$0 [options] address').default('s', null).alias('s', 'server').describe('s', 'whois server').default('f', 0).alias('f', 'follow').describe('f', 'number of times to follow redirects').default('p', null).alias('p', 'proxy').describe('p', 'SOCKS proxy').boolean('v').default('v', false).alias('v', 'verbose').describe('v', 'show verbose results').default('b', null).alias('b', 'bind').describe('b', 'bind to a local IP address').boolean('h').default('h', false).alias('h', 'help').describe('h', 'display this help message');

  if (yargs.argv.h) {
    yargs.showHelp();
    process.exit(0);
  }

  if (yargs.argv._[0] == null) {
    yargs.showHelp();
    process.exit(1);
  }

- this.lookup(yargs.argv._[0], {
+ whois.lookup(yargs.argv._[0], {
    server: yargs.argv.server,
    follow: yargs.argv.follow,
    proxy: yargs.argv.proxy,
    verbose: yargs.argv.verbose,
...

Coxxs avatar Sep 03 '21 17:09 Coxxs

I also have this problem on my Windows 10. But before, this problem did not occur.
It looks like a problem that has occurred in the last few months.

fu-sen avatar Dec 07 '21 08:12 fu-sen