Can I use NPM packages in lambda script?

Webpack would be the only way I know of to do this (basically concatenating all the scripts together). Note they do have some available libraries built in, including fetch:

   // From fetch
    fetch,
    Request,
    Response,
    Headers,

    // URL Standards
    URL,
    URLSearchParams,

    // bas64
    atob,
    btoa,

    // Crypto
    crypto: new Crypto(),
    TextDecoder,
    TextEncoder,

    // Debugging
    console,

    // Async
    setTimeout,
    setInterval,
    clearTimeout,
    clearInterval,
...

As far as issues with webpack, I have not had any - though as you say it may be package dependent.

1 Like