aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.06k stars 573 forks source link

TypeError: fromEnv is not a function #6006

Closed vs223 closed 5 months ago

vs223 commented 5 months ago

Checkboxes for prior research

Describe the bug

code: undefined, TypeError: fromEnv is not a function TypeError: fromEnv is not a function
        at _a (****/node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js:71:16)
        at ****/node_modules/@smithy/property-provider/dist-cjs/index.js:79:27
        at coalesceProvider (****/node_modules/@smithy/property-provider/dist-cjs/index.js:106:18)
        at _SignatureV4S3Express.credentialProvider (****/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)
        at _SignatureV4S3Express.signRequest (****/node_modules/@smithy/signature-v4/dist-cjs/index.js:486:25)
        at ****/node_modules/@aws-sdk/middleware-signing/dist-cjs/index.js:223:21
        at ****/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
        at ****/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:173:18
        at ****/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:97:20
        at ****/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:120:14
        at ****/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
// package.json
{
  "dependencies": {
    "@aws-sdk/client-s3": "^3.554.0",
    "@aws-sdk/credential-providers": "^3.554.0",
    ...
  },
  ...
}

node version: v20.12.0

additional

after add yarn add @aws-sdk/credential-provider-env

`ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/app.e2e-spec.ts.`

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.12.0

Reproduction Steps

this.s3 = new S3(s3ClientConfig);
...
this.s3.getObject({ Bucket: this.bucket, Key: keys });

Observed Behavior

.

Expected Behavior

.

Possible Solution

x

Additional Information/Context

No response

RanVaknin commented 5 months ago

Hi @vs223 ,

code: undefined, TypeError: fromEnv is not a function TypeError: fromEnv is not a function

this suggest that the module was not installed. after you installed the dependency it seems like you are importing it after your jest E2E test has already been torn down.

The code snippet you shared is incomplete, and does not give us enough info to go off of. Can you please better articulate the problem and include a more complete and concise code snippet?

Thanks, Ran~

github-actions[bot] commented 5 months ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] commented 4 months ago

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.