Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package.json+yarn] How to deal with the numerous "@aws-cdk/aws-*" unmet peer dependency warnings #9832

Open
lestephane opened this issue Aug 19, 2020 · 6 comments
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. management/devenv Related to CDK development/build environment p2

Comments

@lestephane
Copy link

I come from the java world and try to reduce my dependencies to the exact set that I need.
So I'm not an npm / yarn expert, but the verbosity I'm having to deal with in the context of installing aws-cdk modules
is a bit intimidating.

When I do a fresh yarn install, I get lots of peer dependencies warnings. What am I supposed to do about it?
If there is nothing I can do about it, how can I avoid seeing these warnings (and indeed why are they warnings at all)?

I think this is more of a generic npm / yarn question, but still, I want to know how people deal with this in the context of the aws-cdk, where each imported module has many peer dependencies, causing many such warnings. I don't like those, they keep reminding me that I'm either doing something wrong, or that yarn is using the wrong level of logging...

Input appreciated, thanks.

package.json fragment

  "dependencies": {
    "@aws-cdk/aws-dynamodb": "^1.59.0",
    "@aws-cdk/aws-ecs": "^1.59.0",
    "@aws-cdk/aws-lambda-event-sources": "^1.59.0",
    "@aws-cdk/aws-sns": "^1.59.0",
    "@aws-cdk/aws-sns-subscriptions": "^1.59.0",
    "@aws-cdk/aws-sqs": "^1.59.0",
    "@aws-cdk/core": "^1.59.0",
...
  }

yarn installoutput fragment

warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/aws-lambda > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/aws-lambda > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/custom-resources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-dynamodb > @aws-cdk/custom-resources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-ecs > @aws-cdk/aws-route53-targets > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning " > @aws-cdk/[email protected]" has unmet peer dependency "constructs@^3.0.2".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
warning "@aws-cdk/aws-lambda-event-sources > @aws-cdk/[email protected]" has unmet peer dependency "@aws-cdk/[email protected]".
@lestephane lestephane added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Aug 19, 2020
@ilknarf
Copy link

ilknarf commented Aug 19, 2020

Seems like this is a yarn feature.
yarnpkg/yarn#5347
yarnpkg/yarn#5347 (comment)

Have you checked node_modules to see if the peer dependencies are in fact installed? I could reproduce this issue, but the dependencies showed up in node_modules as desired.

@SomayaB SomayaB self-assigned this Aug 20, 2020
@SomayaB SomayaB added the management/devenv Related to CDK development/build environment label Aug 20, 2020
@lestephane
Copy link
Author

Have you checked node_modules to see if the peer dependencies are in fact installed?

Yup, they are installed.

yarnpkg/yarn#5347 (comment)

If I depend on @aws-cdk/aws-ecs which in turns depends on 22(!) peer dependencies, and my code could break if I forget to add an explicit dependency on all of them, are these 22 peer dependencies not, in fact, actual transitive dependencies, and should not be declared as peer dependencies but 'real' dependencies in @aws-cdk/aws-ecs?

@ilknarf
Copy link

ilknarf commented Aug 20, 2020

yarnpkg/yarn#5347 (comment)

Because they are dependencies of your dependencies, it throws a warning because it needs to be hoisted by the package manager. If you tried it with npm, it would do the same hoisting, but without printing the most of the warnings.

So no, you won't need to explicitly add the peer dependencies.

(Welcome to JS lol)

@lestephane
Copy link
Author

Ok, but say, I import @aws-cdk/[email protected] but I don't make use of KMS encryption at all in conjunction with Dynamodb, and therefore has unmet peer dependency "@aws-cdk/[email protected]" is of no relevance to me, since all it's saying is "IF you use KMS in combination with DynamoDB, then it must be this aws-kms module version".

I don't care, since I'm not using KMS.

This, to me, points to the real problem, that peerDependencies have not been declared as optional (when applicable).

Looking at package.json for @aws-cdk/aws-dynamodb

  "dependencies": {
    ...
    "@aws-cdk/aws-kms": "1.60.0",
    ...
  },
  ....
  "peerDependencies": {
    ...
    "@aws-cdk/aws-kms": "1.60.0",
    ...
  },

Should there not be as well:

  "peerDependenciesMeta": {
    "@aws-cdk/aws-kms": {
      "optional": true
    }
  }

I think this would remove the warning and make the intent clear, as long as only optional peer dependencies are marked optional of course.

@SomayaB SomayaB assigned SomayaB and unassigned SomayaB Sep 3, 2020
@SomayaB SomayaB added feature-request A feature should be added or improved. and removed guidance Question that needs advice or information. labels Sep 29, 2020
@SomayaB SomayaB assigned eladb and unassigned NGL321 and SomayaB Sep 29, 2020
@eladb
Copy link
Contributor

eladb commented Oct 25, 2020

This will be solved in 2.0 of the AWS CDK. We are planning to release the entire CDK as a single module (aws-cdk-lib) so hopefully this hell will go away.

Here you can find more information about monolithic packaging.

We will consider annotating our deps with peerDependenciesMeta.optional for 1.x in the meantime to reduce the grief.

@eladb eladb added effort/small Small work item – less than a day of effort p1 labels Oct 25, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Oct 26, 2020
@eladb eladb removed their assignment Feb 25, 2021
@fractionalJoe
Copy link

Any update on adding the optional annotation? I architect across many applications for a large enterprise and our migration to 2.0 will not be immediate. In the meantime, as an example, a very small project I'm involved with is getting 62 warnings of this type. When warnings become spam, developers ignore warnings. I believe we can all agree, that is not a desirable outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. management/devenv Related to CDK development/build environment p2
Projects
None yet
Development

No branches or pull requests

7 participants