You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Command}from'commander';constprogram=newCommand();program.name('pm')constbrew=program.command('brew').description('Brew your drinks');;brew.command('tea','Brew your tea');brew.command('coffee','Brew your coffee');program.parse(process.argv);
The call node -r ts-node/register src/index.ts brew coffeeends up with
/my/app/path/node_modules/commander/lib/command.js:1175
throw new Error(executableMissing);
^
Error: 'brew-coffee' does not exist
- if'coffee' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
- no directory for search forlocal subcommand, use .executableDir() to supply a custom directory
at Command._checkForMissingExecutable (/my/app/path/node_modules/commander/lib/command.js:1175:11)
at ChildProcess.<anonymous> (/my/app/path/node_modules/commander/lib/command.js:1306:14)
at ChildProcess.emit (node:events:507:28)
at ChildProcess.emit (node:domain:489:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at processTicksAndRejections (node:internal/process/task_queues:90:21)
Even if I rename the file pm-brew-coffee.ts to brew-coffee.ts, it throws the same error.
I would have expected that the file pm-brew-coffee.ts is getting executed and pm-brew-coffee is shown.
Am I am missing something?
The text was updated successfully, but these errors were encountered:
The confusion between commands with an action handler and ones implemented as stand-alone executable files was more common before the README got updated, but can still cause confusion: #938
The programm
The file structure:
pm-brew-coffee.ts
looks likeThe call
node -r ts-node/register src/index.ts brew coffee
ends up withEven if I rename the file
pm-brew-coffee.ts
tobrew-coffee.ts
, it throws the same error.I would have expected that the file
pm-brew-coffee.ts
is getting executed andpm-brew-coffee
is shown.Am I am missing something?
The text was updated successfully, but these errors were encountered: