Sentry Answers>Node.js>

Critical dependency: the request of a dependency is an expression

Critical dependency: the request of a dependency is an expression

Matthew C.

The Problem

When using the Amazon Web Services (AWS) Software Development Kit (SDK) for JavaScript or the AWS Amplify JavaScript library, you may get the following warning when building your application:

Click to Copy
WARNING in ./node_modules/aws-crt/dist/native/binding.js 54:18-31 Critical dependency: the request of a dependency is an expression @ ./node_modules/aws-crt/dist/native/io.js 16:34-54 @ ./node_modules/aws-crt/dist/index.js 40:24-46

The Solution

Because this is a JavaScript bundler warning triggered by dynamically imported dependencies in the AWS code, you can suppress it by modifying your bundler settings to ignore the following files:

  • node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/load-crt.js
  • node_modules/@aws-sdk/util-user-agent-node/dist-cjs/is-crt-available.js

For example, if your project used webpack:

  • You could add the above files as externals in your webpack.config.js file to prevent them from being bundled. The files would then be retrieved at runtime.

  • You could also use the webpack exclude rule to exclude the AWS SDK from your bundle.

    Click to Copy
    module.exports = { //... module: { rules: [ { test: /\.js$/, exclude: [ './node_modules/@aws-sdk/' ] } ] }, };

Note

The request of a dependency is an expression warning is a JavaScript bundler warning that indicates the presence of dynamically imported dependency. In this case, it is caused by an AWS SDK dependency that is also used by AWS libraries: the AWS Common Runtime (CRT) dependency, which is dynamically imported by a require call by the @aws-sdk package code.

Dynamic imports make JavaScript bundlers less effective at statically analyzing which modules to include in a build.

If a bundler can’t determine which modules to include in the final bundle, it is more likely to add unnecessary code to the bundle by including all the possible modules that an expression might resolve to.

An upcoming release of the AWS SDK for JavaScript will remove the dynamic require call, which will fix this warning.

  • SentryWorkshop: Debugging your Node.js Project With Sentry
  • Syntax.fmListen to the Syntax Podcast
  • Community SeriesIdentify, Trace, and Fix Endpoint Regression Issues
  • ResourcesBackend Error Monitoring 101
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2025 • Sentry is a registered Trademark of Functional Software, Inc.