next-s3-upload
next-s3-upload copied to clipboard
Can't resolve `@aws-sdk/signature-v4-crt` and `aws-crt`
Hey,
first of all, thanks for the library. It works fine so far, the images get uploaded but I always get the following errors. Have you come across this issue already?
Module not found: Can't resolve '@aws-sdk/signature-v4-crt' in './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
./node_modules/next-s3-upload/dist/next-s3-upload.cjs.development.js
./node_modules/next-s3-upload/dist/index.js
./components/forms/upload-form.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in './node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js
./node_modules/@aws-sdk/client-sts/dist-cjs/index.js
./node_modules/next-s3-upload/dist/next-s3-upload.cjs.development.js
./node_modules/next-s3-upload/dist/index.js
./components/forms/upload-form.tsx
Versions Node: 18.15.0 Next: 13.4.7 This package: 0.3.0
If you need further information, just let me know! Thank you!
+1
After running yarn add @aws-sdk/signature-v4-crt aws-crt
, I get the following error:
Critical dependency: the request of a dependency is an expression
Import trace for requested module:
./node_modules/aws-crt/dist/native/binding.js
./node_modules/aws-crt/dist/native/checksums.js
./node_modules/aws-crt/dist/index.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.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
./node_modules/next-s3-upload/dist/next-s3-upload.cjs.development.js
./node_modules/next-s3-upload/dist/index.js
./components/forms/upload-form.tsx
+1
getting same error any solution or fix for it ?
+1
Thanks for the bug report, I'll start investigating this.
One quick question: is it preventing the library from working?
@ryanto no its not preventing it from working, it works fine with these errors.
Ok I just published version 0.3.1
which upgrades the AWS dependencies. Let me know if you still see this error.
Still appearing in 0.3.1
:
- 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 '.\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
./node_modules/next-s3-upload/dist/next-s3-upload.cjs.development.js
./node_modules/next-s3-upload/dist/index.js
./src/components/PhotoUpload.tsx
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
Module not found: Can't resolve 'aws-crt' in '.\node_modules\@aws-sdk\util-user-agent-node\dist-cjs'
Import trace for requested module:
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js
./node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
./node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.js
./node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js
./node_modules/@aws-sdk/client-sts/dist-cjs/index.js
./node_modules/next-s3-upload/dist/next-s3-upload.cjs.development.js
./node_modules/next-s3-upload/dist/index.js
./src/components/PhotoUpload.tsx
Issue stems from the aws sdk and webpack https://github.com/aws/aws-sdk-js-v3/issues/4126
To avoid the warning, its possible to update the webpack config for nextjs.
Update next.config.js:
/** @type {import('next').NextConfig} */
const config = {
// …
webpack: (config, { webpack, isServer, nextRuntime }) => {
// Avoid AWS SDK Node.js require issue
if (isServer && nextRuntime === "nodejs")
config.plugins.push(
new webpack.IgnorePlugin({ resourceRegExp: /^(aws-crt|@aws-sdk\/signature-v4-crt)$/ })
);
return config;
},
// …
};
module.exports = config;
credit to https://github.com/aws-amplify/amplify-js/issues/11030#issuecomment-1663392051
@martinmiglio awesome find!