# Using a package from a second package

**URL:** <https://community.postman.com/t/using-a-package-from-a-second-package/69894>\
**Category:** Help Hub\
**Tags:** package-library\
**Created:** [October 18, 2024, 12:17am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894 "2024-10-18T00:17:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tibiextera](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@tibiextera](https://community.postman.com/u/tibiextera)\
**Post date:** [October 18, 2024, 12:17am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/1 "2024-10-18T00:17:58Z")

</div>

I have created two packages. Let’s call them ‘a’ and ‘b’ for my team ‘t’.

In package `b` I would like to call `myFunction` from package `a`.

I have tried the following:

```auto
// package b
const a = pm.require('@t/a');

function mySecondFunction() {
   a.myfunction();
}

module.exports = { mySecondFunction };

```

When I try to use package `b` in a request script I get the following error:

```auto
Error in package '@t/b': Cannot find module '@t/a'

```

Is this supported? If yes, how should I change my code in package `b` so I can call functions from package `a`?

---

<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 18, 2024, 7:40am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/2 "2024-10-18T07:40:24Z")

</div>

Hey @tibiextera 👋🏻

Referencing packages inside other packages is not currently supported.

Could you explain more about your use case and the need to use a script in this way? It will help us to better understand your requirement.

---

<div class="post-metadata">

**Author:** ![tibiextera](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@tibiextera](https://community.postman.com/u/tibiextera)\
**Post date:** [October 23, 2024, 2:59am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/3 "2024-10-23T02:59:52Z")

</div>

I am creating tests for the current REST API that I am working on. Some tests require that I invoke the REST API with other calls than the main request to set up the data that the main request will use for the test.

I created a package that turns the `pm.sendRequest` function into an async function that returns a Promise.

I was planning to use this in a package that is specific for this current API, while still having it available for other APIs that I might build in the future.

That led to requiring a package from a second package, which, after some more research, seems that it is not possible currently.

---

<div class="post-metadata">

**Author:** ![rings-twice](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rings-twice](https://community.postman.com/u/rings-twice)\
**Post date:** [November 13, 2024, 5:32pm UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/4 "2024-11-13T17:32:06Z")

</div>

I am doing the same thing, and was able to get around this issue by requiring package a in the request script where I called package b, as well as in package b itself.

---

<div class="post-metadata">

**Author:** ![dmitry-epstein-rjf](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@dmitry-epstein-rjf](https://community.postman.com/u/dmitry-epstein-rjf)\
**Post date:** [December 3, 2024, 12:57am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/5 "2024-12-03T00:57:13Z")

</div>

Same here. The clumsy workaround is to require the same dependencies in the package and in the calling script, but this is clearly a misfeature. Require should work correctly in packages. The need for this is obvious. It is the same as why we need packages in the first place: sharing and reusing code.

In my case I wrote some general-purpose utilities, then tried to use them in more specialized packages when I ran into this issue.

---

<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:** [December 3, 2024, 10:15am UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/6 "2024-12-03T10:15:40Z")

</div>

We appreciate the feedback @dmitry-epstein-rjf. 🙏🏻

The Package Library is still a relatively new feature in Postman which gaining traction amongst the user base.

It’s not a finished feature and we’re always gathering feedback in order to improve the overall functionality for you all.

This feature request is on the roadmap, as well as a bunch of other items that have been requested.

There is no timeline for these features just yet but more information will be shared once we have some new updates for you all.

Appreciate you using the feature and please do keep the feedback coming, it’s the best way that we can improve Postman for everyone.

---

<div class="post-metadata">

**Author:** ![tibiextera](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@tibiextera](https://community.postman.com/u/tibiextera)\
**Post date:** [December 6, 2024, 8:45pm UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/7 "2024-12-06T20:45:50Z")

</div>

Thank you for keeping this request in mind. The packages feature could be a really useful feature when this and another couple of issues will be resolved.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [January 5, 2025, 8:46pm UTC](https://community.postman.com/t/using-a-package-from-a-second-package/69894/8 "2025-01-05T20:46:28Z")

</div>

Closed on January 5, 2025, 8:46pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
