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

Module not found #5135

Closed
DrillableBit opened this issue Aug 19, 2023 · 7 comments · Fixed by #5225
Closed

Module not found #5135

DrillableBit opened this issue Aug 19, 2023 · 7 comments · Fixed by #5225
Assignees
Labels
bug This issue is a bug. investigating Issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue

Comments

@DrillableBit
Copy link

Describe the bug

Start a fresh next.js application ( create-next-app myApp) - use app router.

npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner

import into a file (don't use):
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

Expected Behavior

  • warn ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
    Module not found: Can't resolve '@aws-sdk/signature-v4-crt' in 'C:\Users\aapli\Desktop\Programming\help-s3\node_modules@aws-sdk\signature-v4-multi-region\dist-cjs'

Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/s3-request-presigner/dist-cjs/presigner.js
./node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js
./src/_lib/afile.jsx
./src/app/page.tsx

in the console

Current Behavior

  • warn ./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
    Module not found: Can't resolve '@aws-sdk/signature-v4-crt' in 'C:\Users\aapli\Desktop\Programming\help-s3\node_modules@aws-sdk\signature-v4-multi-region\dist-cjs'

Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/s3-request-presigner/dist-cjs/presigner.js
./node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js
./src/_lib/afile.jsx
./src/app/page.tsx

Reproduction Steps

npx create-next-app
typescript, tailwind, approuter

npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner

import into a file (don't use):
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.395.0

Environment details (OS name and version, etc.)

windows

@DrillableBit DrillableBit added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 19, 2023
@yenfryherrerafeliz yenfryherrerafeliz transferred this issue from aws/aws-sdk-js Aug 23, 2023
@yenfryherrerafeliz yenfryherrerafeliz self-assigned this Aug 23, 2023
@davincios
Copy link

I can confirm that I have the same issue. It is there already for quite a while and resurfaces now and then.

@davincios
Copy link

davincios commented Sep 5, 2023

The bug was introduced about 2 years ago I believe.

PLEASE DO NOT CLOSE THIS ISSUE AS HAPPENDS ALL THE TIME.

But how to do a fix for yourself @DrillableBit

  • use the same dependency version for @AWS-SDK client-s3 and s3-request presigner.
  • use a version earlier than 3.3

what works in my next.js typescript project is this:

"@aws-sdk/client-s3": "3.3.0",
"@aws-sdk/s3-request-presigner": "3.3.0",

@yenfryherrerafeliz yenfryherrerafeliz added investigating Issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 5, 2023
@yenfryherrerafeliz
Copy link
Contributor

Hi @DrillableBit, @davincios, I will investigate this issue and I will get back to you.

Thanks!

@davincios
Copy link

davincios commented Sep 5, 2023

Hi @DrillableBit, @davincios, I will investigate this issue and I will get back to you.

Thanks!

Hi @yenfryherrerafeliz

I would really appreciate it, and am happy to provide any information possible.

There is a lot of libraries that are depending on these two packages and all have to encounter the build error warnings or security code smells of this issue (when using the 3.3 or earlier versions to remove the build error warning).

It probably affects thousands of people.

I am also happy to provide you an example repository with the issue to replicate the error or jump with you on a call.

@davincios
Copy link

The bug was introduced about 2 years ago I believe.

PLEASE DO NOT CLOSE THIS ISSUE AS HAPPENDS ALL THE TIME.

But how to do a fix for yourself @DrillableBit

  • use the same dependency version for @AWS-SDK client-s3 and s3-request presigner.
  • use a version earlier than 3.3

what works in my next.js typescript project is this:

"@aws-sdk/client-s3": "3.3.0", "@aws-sdk/s3-request-presigner": "3.3.0",

This unfortunately is not a solution for me because it doesn't pass our code security scanner.

So I probably will have to create a custom lib as a hot fix before it is fixed by Amazon. As this issue is there already for 5 months. So if you find any additional information as well then that would be super helpful @yenfryherrerafeliz

@lutfi-haslab
Copy link

lutfi-haslab commented Oct 5, 2023

Hello, i have the same issue, this is weird. I only want to import @aws-sdk/client-s3 and it's just working fine. However i got error when building next app version 13.

here the output:

./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted 

Import trace for requested module:
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js
./node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js
./node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js
./node_modules/@aws-sdk/client-s3/dist-cjs/index.js
./src/components/modal.component.tsx
./src/app/projects/[id]/applications/page.tsx

In dev mode, i can hide the message by configure the next config as below:

  webpack: (config, { isServer, nextRuntime, webpack }) => {
    // Avoid AWS SDK Node.js require issue
    if (isServer && nextRuntime === "nodejs")
      config.plugins.push(
        new webpack.IgnorePlugin({ resourceRegExp: /^aws-crt$/ })
      );
    return config;
  },

Everything works fine, but the message is annoying and can't trace the error. I would'nt install aws-sdk since the bundle really big.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. investigating Issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants