typescript commander program.version is not a function
See original GitHub issueI am getting following error while using commander with typescript.
TypeError: program.version is not a function
TypeError: program.option is not a function
index.ts
import * as program from 'commander';
program
.version('1.0.0')
.option('-p, --peppers', 'Add peppers')
.option('-P, --pineapple', 'Add pineapple')
.option('-b, --bbq', 'Add bbq sauce')
.parse(process.argv);
console.log(program);
package.json
{
"name": "typescript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^10.12.18",
"commander": "^2.19.0"
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Use commander in typescript - node.js - Stack Overflow
With your first code snippet and the following dependencies, I do not get an error: "dependencies": { "commander": "^2.11.0" } ...
Read more >commander - npm
Version option The default option flags are -V and --version , and when present the command prints the version number and exits. You...
Read more >Building a TypeScript CLI with Node.js and Commander
Commander.js is a powerful library for building command-line interface tools with TypeScript. Learn how to use Commander with TypeScript.
Read more >How to set up TypeScript
You can use npm to install TypeScript globally, this means that you can use the tsc command anywhere in your terminal. To do...
Read more >How to use the commander.version function in ... - Snyk
/usr/bin/env node var program = require('commander'); var cli = require('./app/cli.js'); program .version('0.0.1'); // .description('Google Cloud Functions ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I found the difference, in order to make it working you have to set
"esModuleInterop": true,intsconfig.jsonHi, I just got the same problem solved
@Toub your sollution works, but if you have your program split to more then one file, you will get different instances in each file.
@Zikoel @akki005 just try import synax without asterisk, it works for me with Node 10.15.1 and Commander 2.20.0