Why is my custom console command throwing Calling unknown method: ...getAcceptsJson? I have a module with a console controller (ScriptsController):

namespace modules\vetscripts\console\controllers;

use yii\console\Controller;
use yii\console\ExitCode;
use modules\vetscripts\VetScripts;

class ScriptsController extends Controller
{
    public function actionExpiring()
    {
        VetScripts::$instance-&gt;scripts-&gt;expiringScripts();

        return ExitCode::OK;
    }
}


When I run it using $ ./craft vetscripts/scripts/expiring I get the following error and stack trace:

2019-08-05 11:35:24 [-][-][-][error][yii\base\UnknownMethodException] yii\base\UnknownMethodException: Calling unknown method: craft\console\Request::getAcceptsJson() in /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /Users/steven/Code/vetscripts/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Component-&gt;__call('getAcceptsJson', Array)
#1 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller-&gt;runAction('expiring', Array)
#2 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module-&gt;runAction('vetscripts/scri...', Array)
#3 /Users/steven/Code/vetscripts/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application-&gt;runAction('vetscripts/scri...', Array)
#4 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application-&gt;runAction('vetscripts/scri...', Array)
#5 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application-&gt;handleRequest(Object(craft\console\Request))
#6 /Users/steven/Code/vetscripts/craft(22): yii\base\Application-&gt;run()
#7 {main}


This is my first time attempting a custom console command, which I need to get a cron job up and running. Is there something I'm missing here?

Thanks!
I had a hunch that a web controller with a similar name was getting called, and indeed that is what was happening. In my module's init method I was setting the controller namespace like this:

$this-&gt;controllerNamespace = 'modules\vetscripts\controllers';`


By default, then, the console was going to the web controller, I'm assuming. @Selvin pointed me in the right direction with this:

use craft\console\Application as Console

...

public function init()
{
    ...
    if (Craft::$app instanceof Console) {
        $this-&gt;controllerNamespace = 'modules\vetscripts\console\controllers';
    }
    ...
}


Now I can see my module's custom console actions when running ./craft from the console.