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
program.version('1.0.0','-v, --version','output the current version').option('-p, --port <number>','port to serve Restapify instance')
Sadly it seems to conflict with a property on Command:
option 'port' clashes with existing property 'port' on Command
- call storeOptionsAsProperties(false) to store option values safely,
- or call storeOptionsAsProperties(true) to suppress this check,
- or change option name
program.storeOptionsAsProperties(false).passCommandToAction(false)program.version('1.0.0','-v, --version','output the current version').option('-p, --port <number>','port to serve Restapify instance')
But then I get this curious error which disturb me a bit because I call it before defining options:
call .storeOptionsAsProperties() before adding options
Has someone an idea what I'm doing wrong here?
The text was updated successfully, but these errors were encountered:
The way the options are stored by default is changing in Commander 7 because of the potential for conflicts with existing properties. See #1229 for some history.
However, I can not reproduce either the port conflict or the error to call .storeOptionsAsProperties() before adding options with your program fragment.
Are you using the global program rather than creating a new Command? I suspect some other piece of code is also using the global, and adding a port option with a default value!
I expect the behaviour will change if you create a new Command, but you might want to track down the source of the conflict too:
Thanks @shadowspawn you are right I was just using import { program } from 'commander'. With the instantiation of the Command class it's working like a charm 👍 I just figured that it was well mentioned in the README to instantiate this class so sorry to waste you time 😅
i've written this tiny cli with the option
port
:Sadly it seems to conflict with a property on
Command
:So I made this change like mentioned here:
But then I get this curious error which disturb me a bit because I call it before defining options:
Has someone an idea what I'm doing wrong here?
The text was updated successfully, but these errors were encountered: