# Node.js: Fix Critical Dependency Webpack Warning

> Suppress this webpack bundler warning from a dynamically required AWS SDK dependency by adding the affected files as externals or excluding them from your bundle

**URL:** https://sentry.io/answers/critical-dependency-the-request-of-a-dependency-is-an-expression/

---

## The Problem

When using the [Amazon Web Services (AWS) Software Development Kit (SDK) for JavaScript](https://github.com/aws/aws-sdk-js-v3) or the [AWS Amplify JavaScript library](https://github.com/aws-amplify/amplify-js), you may get the following warning when building your application:

```
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](https://webpack.js.org/configuration/externals/#root) 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](https://webpack.js.org/configuration/module/#ruleexclude) to exclude the AWS SDK from your bundle.

  ```js
  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.

A [2023 release of the AWS SDK for JavaScript](https://github.com/aws/aws-sdk-js-v3/issues/5229) replaced the dynamic `require` call with an explicit opt-in: import or require `@aws-sdk/signature-v4-crt` yourself if your application uses S3 Multi-Region Access Points or EventBridge, and the SDK will use it without triggering this bundler warning.

---

*Source: [sentry.io/answers/critical-dependency-the-request-of-a-dependency-is-an-expression/](https://sentry.io/answers/critical-dependency-the-request-of-a-dependency-is-an-expression/)*
