node-modules/common-bin

Does not support typescript commonjs module

hacke2 opened this issue · 0 comments

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "./lib",
    "target": "es2015",
    "moduleResolution": "node",
    "strict": true,
    "sourceMap": true,
    "removeComments": true,
    "importHelpers": true,
    "noEmitOnError": false,
    "noImplicitAny": false,
    "skipLibCheck": true,
    "declaration": true,
  },
  "exclude": [
    "node_modules",
    "lib"
  ],
  "include": [
    "./src/**/*"
  ]
}

If use es module will throw a error.

import * as Command from 'common-bin';

export default class CheckCommand extends Command {
  constructor(rawArgv: string[]) {
    super(rawArgv);
    this.yargs.usage('check me');
  }

  run(context: Command.Context) {
    
  }

  get description(): string {
    return 'Clone a repository into a new directory';
  }
}

The error:

AssertionError [ERR_ASSERTION]: command class should be sub class of common-bin
    at MainCommand.add (/Users/hacke2/projj/gitlab.alipay-inc.com/xinglong.wangwxl/vscode-extension-scan/node_modules/_common-bin@2.8.1@common-bin/lib/command.js:109:7)
    at MainCommand.load (/Users/hacke2/projj/gitlab.alipay-inc.com/xinglong.wangwxl/vscode-extension-scan/node_modules/_common-bin@2.8.1@common-bin/lib/command.js:86:14)
    at new MainCommand (/Users/hacke2/projj/gitlab.alipay-inc.com/xinglong.wangwxl/vscode-extension-scan/lib/index.js:9:14)
    at Object.<anonymous> (/Users/hacke2/projj/gitlab.alipay-inc.com/xinglong.wangwxl/vscode-extension-scan/lib/bin/vc.js:5:1)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)