aws-sdk-js-v3
aws-sdk-js-v3 copied to clipboard
Unable to use S3 with TypeScript and Yarn 3, missing dependencies
Describe the bug
We are unable to use AWS S3 SDK with TypeScript and Yarn 3 as some types dependencies (from @aws-sdk/node-config-provider
) are missing in several packages: @aws-sdk/config-resolver
, @aws-sdk/middleware-bucket-endpoint
and @aws-sdk/middleware-retry
.
Steps to reproduce
Minimal repository https://github.com/vhiairrassary/aws-sdk-js-v3-bug-report
Running yarn
then yarn run build
will produce the following errors (truncated):
.yarn/cache/@aws-sdk-config-resolver-npm-3.40.0-70d76c189b-0f8a153e1c.zip/node_modules/@aws-sdk/config-resolver/dist-types/endpointsConfig/NodeUseDualstackEndpointConfigOptions.d.ts:1:39 - error TS2307: Cannot find module '@aws-sdk/node-config-provider' or its corresponding type declarations.
1 import { LoadedConfigSelectors } from "@aws-sdk/node-config-provider";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.yarn/cache/@aws-sdk-config-resolver-npm-3.40.0-70d76c189b-0f8a153e1c.zip/node_modules/@aws-sdk/config-resolver/dist-types/endpointsConfig/NodeUseFipsEndpointConfigOptions.d.ts:1:39 - error TS2307: Cannot find module '@aws-sdk/node-config-provider' or its corresponding type declarations.
1 import { LoadedConfigSelectors } from "@aws-sdk/node-config-provider";
I think the issue is due to missing types dependencies. Yarn 3, when used using PnP operating under strict mode (the default) requires dependencies to be correctly declared for every package. To fix the issue, apply the following patch (to the minimal repository, to ask Yarn 3 to override dependencies until fixed upstream) to add missing dependencies:
diff --git a/.yarnrc.yml b/.yarnrc.yml
index 9e303c3..29a8ca1 100644
--- a/.yarnrc.yml
+++ b/.yarnrc.yml
@@ -1 +1,12 @@
yarnPath: .yarn/releases/yarn-3.1.1.cjs
+
+packageExtensions:
+ "@aws-sdk/config-resolver@*":
+ peerDependencies:
+ "@aws-sdk/node-config-provider": "*"
+ "@aws-sdk/middleware-bucket-endpoint@*":
+ peerDependencies:
+ "@aws-sdk/node-config-provider": "*"
+ "@aws-sdk/middleware-retry@*":
+ peerDependencies:
+ "@aws-sdk/node-config-provider": "*"
Running yarn
then yarn run build
now works as expected.
Tried doing that and looks like I've partially solved, now I'm getting:
Cannot find module '@aws-sdk/types' or its corresponding type declarations.
1 import { ParsedIniData } from "@aws-sdk/types";
~~~~~~~~~~~~~~~~
I have the same issue, is there any update on providing yarn 3 support?
This could have been fixed by https://github.com/aws/aws-sdk-js-v3/pull/2928. That PR is now out of date, but the issue is a simple package dependency mistake that is exposed when using yarn or pnpm.
Confirmed this issue.
Will assign to the development team and added a p1
tag because I see it impacts multiple users.
Thanks.
Just bumping this here. We ran into this issue too because the @aws-sdk/types package and the ones above were listed as devDependencies instead of dependencies.
This doesn't work because it's being reexported and is therefore a peer or actual dependency when trying to examine the package for self-consistency.
We have moved all types imports to dependencies and not devDeps.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.