Pop-Code / nestjs-console

A nestjs module that provide a cli to your application.
https://www.npmjs.com/package/nestjs-console
MIT License
561 stars 26 forks source link

Cannot find exitOverride function #128

Closed daydarkln closed 4 years ago

daydarkln commented 4 years ago

Describe the bug A clear and concise description of what the bug is. I catch a bug when trying to run console command via yarn run:

(node:15413) UnhandledPromiseRejectionWarning: TypeError: parent.command(...).exitOverride is not a function
    at ConsoleService.createCommand (/home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/src/service.ts:167:14)
    at /home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/src/module.ts:34:30
    at Set.forEach (<anonymous>)
    at ConsoleModule.scan (/home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/src/module.ts:25:22)
    at BootstrapConsole.useDecorators (/home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/src/bootstrap/abstract.ts:80:23)
    at BootstrapConsole.<anonymous> (/home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/src/bootstrap/abstract.ts:97:18)
    at Generator.next (<anonymous>)
    at fulfilled (/home/daydark-pc/GitLab/mp3studio-api/node_modules/nestjs-console/lib/bootstrap/abstract.js:5:58)
(node:15413) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15413) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

To Reproduce Steps to reproduce the behavior:

  1. Use this gist to run project https://gist.github.com/daydarkln/f53f06c7bbb94344f1d00becc82471c1
  2. run yarn run console:dev update-featured-videos

Expected behavior This command must log hi

Desktop (please complete the following information):

Rmannn commented 4 years ago

Please downgrade commander to 4.1.1

daydarkln commented 4 years ago

Please downgrade commander to 4.1.1

What do you mean? There isn't such dependency

Rmannn commented 4 years ago

There is a dependency. nestjs-console depends on commander package. It's a peer dependency. I updated the Readme yesterday to point out the good version.

npm install commander@4.1.1

Commander package moved to version 5.0.0. And this version is not compatible with this package. On this repo v5 branch is in progress and will be published to npm soon.

daydarkln commented 4 years ago

Oh, I see. Thanks. But if someone doesn't want to install dep that never use directly? Maybe you replace it from devDep to dep?

Rmannn commented 4 years ago

Other package like nestjs-cli that is widely used also depends on commander. As I want to be flexible, I allow you to use any version of your choice (minor or patch). This is the reason commander is a peer dependency and not a direct dependency. I always keep this package up to date with major releases of commander. Except this time, I am late...

daydarkln commented 4 years ago

Ok. Thank you a lot for your work.

Rmannn commented 4 years ago

Latest npm version 3.0.1 is now sync with commander v5.

mtdewulf commented 4 years ago

I ran into this bug just now with version 3.0.6. I had to manually install commander@5.0.0 to get things working. I think the commander package dependency needs to be promoted from dev dependency to full dependency?

Rmannn commented 4 years ago

Commander is a peer dependency because it's also used by nestjs cli. We won't force a version of nestjs framework, so we decide to let you choose which version to pick. That's why it's up to you to install commander.