serverless / components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
https://www.serverless.com
Apache License 2.0
2.31k stars 182 forks source link

Unmet peer dependency (inquirer) #743

Closed davehensley closed 3 years ago

davehensley commented 4 years ago

Description

The dependency inquirer-autocomplete-prompt was added in e1136d7, but it requires inquirer as a peer dependency (which was not added).

Additional Data

warning "serverless > @serverless/components > inquirer-autocomplete-prompt@1.0.2" has unmet peer dependency "inquirer@^5.0.0 || ^6.0.0".
medikoo commented 4 years ago

@davehensley thanks for report. Still in our setup, inquirer is provided via @serverless/inquirer. Adding it to dependencies here would be just confusing and error prone.

Ideally this warning should be muted, but I'm not sure if there's a way.

tonivdv commented 3 years ago

Hi @medikoo ,

With yarn v1 it doesn't seem possible to mute the warning. However it is/will be possible in yarn v2 as per https://github.com/yarnpkg/yarn/issues/6672

So I guess you could close this issue?

medikoo commented 3 years ago

Thanks @tonivdv for info!

lensbart commented 3 years ago

Still in our setup, inquirer is provided via @serverless/inquirer. [...] Ideally this warning should be muted, but I'm not sure if there's a way.

I’m not sure if this is the best solution. Following the setup guide for Apollo GraphQL serverless, all Yarn 2 users will get to see the following warning:

YN0002: │ @serverless/components@npm:3.8.2 doesn't provide inquirer (pbc6ef), requested by inquirer-autocomplete-prompt

Which can be suppressed with the following addition to .yarnrc.yml:

packageExtensions:
  # awaiting fix: https://github.com/serverless/components/issues/743
  '@serverless/components@*':
    dependencies:
      inquirer: '*'

But this reveals that the versions don’t match (i.e. why the dependency resolution has been made a bit more strict in the first place):

➤ YN0060: │ @serverless/components@npm:3.8.2 provides inquirer (pbc6ef) with version 8.0.0, which doesn't satisfy what inquirer-autocomplete-prompt requests

Which can be suppressed via

packageExtensions:
  # awaiting fix: https://github.com/serverless/components/issues/743
  inquirer-autocomplete-prompt@*:
    peerDependenciesMeta:
      inquirer:
        optional: true

But this is not a good idea, because inquirer is in fact required by inquirer-autocomplete-prompt.

So the most correct & elegant solution seems to be to include inquirer in the dependencies, of this package, no?

Adding it to dependencies here would be just confusing and error prone.

Not sure how it would be error-prone, but I’m not familiar with this repository, so maybe I’m missing something?

kamilpp commented 1 year ago

Just upgraded yarn from v1 to v3 and and experiencing this warning each time yarn install is executed

➤ YN0002: │ @serverless/components@npm:3.18.2 doesn't provide inquirer (p5f8cf), requested by inquirer-autocomplete-prompt

The warning comes from serverless sub-dependency: @serverless/components package.

inquirer-autocomplete-prompt is used only in one place: https://github.com/serverless/components/blob/df2d3f34a09758a203838267586befa21bb4e104/src/cli/interactive-onboarding/cn.js#L16

And as you can see, it uses custom inquirer from https://github.com/serverless/components/blob/df2d3f34a09758a203838267586befa21bb4e104/src/cli/interactive-onboarding/cn.js#L5

which is provided here https://github.com/serverless/utils/blob/153b340d7235fb6fdd8efee867e173d9928c64c2/inquirer/index.js#L36

So as you can see, inquirer package is shipped with serverless via custom implementation so imho you can safely mark it as optional:

packageExtensions:
  # incorrect 'serverless' package configuration – mark 'inquirer' optional to silence yarn warnings
  # see https://github.com/serverless/components/issues/743
  inquirer-autocomplete-prompt@*:
    peerDependenciesMeta:
      inquirer:
        optional: true