# Can I use NPM packages in lambda script?

**URL:** <https://discuss.dgraph.io/t/can-i-use-npm-packages-in-lambda-script/15115>\
**Category:** Dgraph Cloud\
**Tags:** kind:question, lambda\
**Created:** [July 28, 2021, 5:37pm UTC](https://discuss.dgraph.io/t/can-i-use-npm-packages-in-lambda-script/15115 "2021-07-28T17:37:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poolshark](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/poolshark/32/10074_2.png) [@Poolshark](https://discuss.dgraph.io/u/Poolshark)\
**Post date:** [July 28, 2021, 5:37pm UTC](https://discuss.dgraph.io/t/can-i-use-npm-packages-in-lambda-script/15115/1 "2021-07-28T17:37:07Z")

</div>

Hi,

I finally got the Cloud API running and can now deploy lambda scripts from my local machine. Obviously lambdas make only sense (e.g. connecting to another server to fetch an auth token) if I can use NPM packages like `node-fetch` for example. I was following your blogs and the source of the deprecated `slash-graphql` and you were using **webpack** to bundle all of the sources together and push it to the cloud. Unfortunately I have a problem with `target: webworker` in the webpack config. I get loads of errors since I guess some NPM packages are not supported.

Does anyone have the same problem? How did you solve this? Can we use NPM packages directly in lambda scripts?

Thanks!

---

<div class="post-metadata">

**Author:** ![iluminae](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/iluminae/32/7367_2.png) [@iluminae](https://discuss.dgraph.io/u/iluminae)\
**Post date:** [July 28, 2021, 6:09pm UTC](https://discuss.dgraph.io/t/can-i-use-npm-packages-in-lambda-script/15115/2 "2021-07-28T18:09:30Z")

</div>

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:

```auto
   // 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.
