# Unable to use Request module in js library

**URL:** <https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590>\
**Category:** Help Hub\
**Created:** [October 25, 2019, 9:01pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590 "2019-10-25T21:01:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derrick.Boyd](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derrick.Boyd](https://community.postman.com/u/Derrick.Boyd)\
**Post date:** [October 25, 2019, 9:01pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/1 "2019-10-25T21:01:52Z")

</div>

Im attempting to use the request and limiter modules in a test and getting an error. My code and error looks like this;

```
var request = require('request');
var RateLimiter = require('limiter').RateLimiter;

var limiter = new RateLimiter(100, 1000);
var throttledRequest = function() {
    var requestArgs = routes;
    limiter.removeTokens(1, function() {
        request.apply(this, requestArgs);
    });
};

```

Error | Cannot find module ‘request’

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 25, 2019, 9:41pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/2 "2019-10-25T21:41:12Z")

</div>

Hey @Derrick.Boyd,

Welcome to the Postman community!! 👋

I’m not sure where you’ve found an example saying that you could use those modules within the sandbox but it’s not actually possible.

There are only a limited number of external modules that can be used in the Sandbox environment, the full list can be found here:

[https://learning.getpostman.com/docs/postman/scripts/postman\_sandbox\_api\_reference/](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/)

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 26, 2019, 1:44pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/3 "2019-10-26T13:44:21Z")

</div>

The most obvious cause is that you did not install the request module locally in your node project.

```auto
npm install request --save

```

---

<div class="post-metadata">

**Author:** ![Derrick.Boyd](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derrick.Boyd](https://community.postman.com/u/Derrick.Boyd)\
**Post date:** [October 26, 2019, 2:08pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/4 "2019-10-26T14:08:52Z")

</div>

Not exactly sure how to do that? Where am placing that script?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 26, 2019, 2:10pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/5 "2019-10-26T14:10:27Z")

</div>

Are you trying to do this within the Postman application? Or on an external node project?

---

<div class="post-metadata">

**Author:** ![Derrick.Boyd](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derrick.Boyd](https://community.postman.com/u/Derrick.Boyd)\
**Post date:** [October 26, 2019, 2:11pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/6 "2019-10-26T14:11:31Z")

</div>

In the postman application. I didnt think adding additional modules was possible inside of postman

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 26, 2019, 2:16pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/7 "2019-10-26T14:16:17Z")

</div>

There are a few hacky ways that folks have tried but you can’t add those modules like that.

That’s why I replied with this… 🙂

> [@Unable to use Request module in js library](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/2):
>
> Hey @Derrick.Boyd, Welcome to the Postman community!! wave I’m not sure where you’ve found an example saying that you could use those modules within the sandbox but it’s not actually possible. There are only a limited number of external modules that can be used in the Sandbox environment, the full list can be found here: [https://learning.getpostman.com/docs/postman/scripts/postman\_sandbox\_api\_reference/](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/)

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 26, 2019, 2:22pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/8 "2019-10-26T14:22:57Z")

</div>

> [@Derrick.Boyd](#):
>
> Not exactly sure how to do that? Where am placing that script?

You have use the code generator for NodeJs. So I have assumed that you are using node.

require(…) does not work in Postman.

What the problem you are trying to solve?

---

<div class="post-metadata">

**Author:** ![Derrick.Boyd](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@Derrick.Boyd](https://community.postman.com/u/Derrick.Boyd)\
**Post date:** [October 26, 2019, 2:45pm UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/9 "2019-10-26T14:45:48Z")

</div>

I have an array of requests I need to send.  
ex;  
var routes = [  
[https://route1.com](https://route1.com)  
[https://route2.com](https://route2.com)  
[https://route](https://route) [3.com](http://3.com)  
]

The array can be quite large so I to limit the amount of requests that can be sent per second. I also want to implement exponential back off just in case the response is slower then expected but I haven’t gotten that far yet

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 29, 2019, 9:30am UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/10 "2019-10-29T09:30:04Z")

</div>

You are kindof at the limits of what Postman can do. Consider looking into tools like JMeter or Gatling for setting such params.

You can add a delay after each request, thus limiting how many requests you send. I would export the list of requests to an external file and use them as iterations.

You cannot increase or decrease the rate.

Alternatively, you can simply build your own NodeJs script and run it separately from Postman.

---

<div class="post-metadata">

**Author:** ![Anumundada](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Anumundada](https://community.postman.com/u/Anumundada)\
**Post date:** [November 2, 2020, 12:09am UTC](https://community.postman.com/t/unable-to-use-request-module-in-js-library/8590/11 "2020-11-02T00:09:03Z")

</div>

HEllo

When I installed request , got the warning " deprecated request@2.88.2: request has been deprecated"

Is there any other Library we can use? or this is still usuable?
