# Requiring a package from the package library is unreliable

**URL:** <https://community.postman.com/t/requiring-a-package-from-the-package-library-is-unreliable/71733>\
**Category:** Help Hub\
**Tags:** scripts, bug, package-library\
**Created:** [November 26, 2024, 7:13pm UTC](https://community.postman.com/t/requiring-a-package-from-the-package-library-is-unreliable/71733 "2024-11-26T19:13:43Z")\
**Posts on this page:** 3\
**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:** [November 26, 2024, 7:13pm UTC](https://community.postman.com/t/requiring-a-package-from-the-package-library-is-unreliable/71733/1 "2024-11-26T19:13:44Z")

</div>

#### The problem (aka bug)

I am using Postman on Windows 11.

I have created a package named ‘extera-explorer-api’ and I am trying to use it in a post request script.

The package contains at the bottom the exports:

```auto
module.exports = {
    verifyLoginResponse,
    verifyUser,
    verifyToken,
    verifyTokens
};

```

The post-request script is:

```auto
const apiTests = pm.require('@exteradesign/extera-explorer-api');

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

const responseBody = pm.response.json();

apiTests.verifyLoginResponse(responseBody, 'login response')

pm.environment.set("accessToken", responseBody.tokens.access.token);
pm.environment.set("refreshToken", responseBody.tokens.refresh.token);

```

I get three different behaviors when executing the request:

1. The script runs successfully without any errors. This is what I expect to happen all the time, but it does not.
2. The request evaluates the test that is directly in the post-request script but then fails with "Error: Cannot find package ‘@exteradesign/extera-explorer-api’
3. The request evaluates all tests, both the one in the post-request script and the ones in the `verifyLoginResponse` function from the package, but the console shows the "Error: Cannot find package ‘@exteradesign/extera-explorer-api’

#### Observations

The first behavior seems to happen only the day I created the package. It may be that it will happen again after I restart Postman, but I have not tried.

The second behavior happens after I wake up my laptop and try to send the request. Repeatedly sending the request exhibits the same behavior.

The third behavior happened after I fiddled with the request script (not the package) and then reverting (via undo) to the original script. I am not sure what made it change from the second to the third behavior.

#### Expected behavior

I expect only the first behavior: reliably being able to use the exports from the package.

---

<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:** [November 26, 2024, 7:21pm UTC](https://community.postman.com/t/requiring-a-package-from-the-package-library-is-unreliable/71733/2 "2024-11-26T19:21:35Z")

</div>

#### An update

After restarting Postman, it reverted to the first behavior (everything working fine).

Also, regarding the third behavior: while the tests contained in `verifyLoginResponse` were listed as `Pass`, the script did not execute the subsequent code lines. I noticed this when I looked at the environment variables and did not find the `accessToken` or the `refreshToken` variables.

---

<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:** [December 26, 2024, 7:22pm UTC](https://community.postman.com/t/requiring-a-package-from-the-package-library-is-unreliable/71733/3 "2024-12-26T19:22:05Z")

</div>

Closed on December 26, 2024, 7:22pm UTC

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