question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@aws-sdk/client-s3 makes node_modules too large

See original GitHub issue

Describe the bug

When @aws-sdk/client-s3@3.29.0 is installed, it downloads aws-crt as a dependency which is about 200MB in size. It occupies about 60MB even when we compress it.

My team updates the lambda function by directly zipping the directory and uploading it, but we can’t do it anymore because we hit the size limit of the allowed archive size.

The problem is gone after we downgrade @aws-sdk/client-s3 to 3.28.0, but we’d like to use the most recent version if possible.

Your environment

SDK version number

@aws-sdk/client-s3@3.29.0

Is the issue in the browser/Node.js/ReactNative?

Node.js

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ml1nkcommented, Sep 3, 2021

In addition since aws-crt includes a native blob which does not support alpine, it fails for example on node:16.8.0-alpine.

ERROR: Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /opt/main/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node)
4reactions
moltarcommented, Sep 3, 2021

After bundling using esbuild and deploying to Lambda we are getting the following errors:

AWS CRT binary not present in any of the following locations:\n\t/bin/native/aws-crt-nodejs\n\t/bin/linux-x64/aws-crt-nodejs
    "stack": [
        "Error: AWS CRT binary not present in any of the following locations:",
        "\t/bin/native/aws-crt-nodejs",
        "\t/bin/linux-x64/aws-crt-nodejs",
        "    at null.node_modules/aws-crt/dist/native/binding.js (/node_modules/aws-crt/lib/native/binding.js:46:11)",
        "    at __require (/var/task/index.js:41:45)",
        "    at null.node_modules/aws-crt/dist/native/crt.js (/node_modules/aws-crt/lib/native/crt.ts:18:1)",
        "    at __require (/var/task/index.js:41:45)",
        "    at null.node_modules/aws-crt/dist/index.js (/node_modules/aws-crt/lib/index.ts:17:1)",
        "    at __require (/var/task/index.js:41:45)",
        "    at null.node_modules/@aws-sdk/signature-v4-crt/dist/cjs/CrtSignerV4.js (/node_modules/@aws-sdk/signature-v4-crt/src/CrtSignerV4.ts:22:1)",
        "    at __require (/var/task/index.js:41:45)",
        "    at null.node_modules/@aws-sdk/signature-v4-crt/dist/cjs/index.js (/node_modules/@aws-sdk/signature-v4-crt/src/index.ts:1:1)",
        "    at __require (/var/task/index.js:41:45)"
    ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

How we halved the publish size of modular AWS SDK for ...
For example, installing @aws-sdk/client-sts@3.33.0 creates a node_modules with size of 8.9 MB. The client-sts is of size 1.4 MB and contains 115 ...
Read more >
Nodejs modularized aws-sdk v3 size getting increased
1 Answer 1 · Don't push aws-sdk to the lambda function. · Lambda will provide all necessary SDK modules(v2 & v3) during runtime,...
Read more >
Cleanup the node_modules for a lighter Lambda Function
Any nodejs project carries a bulky folder - the node_modules - that carries all the modules and dependencies that the application would need. ......
Read more >
aws-sdk/client-s3
AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native. Latest version: 3.238.0, last published: 3 days ago.
Read more >
How to migrate your Node.js Lambda functions to AWS ...
You only require (or import ) the module for the specific service client you need, rather than importing the entire aws-sdk module.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found