# \`pm.require is not a function\` Error During Performance Tests

**URL:** <https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901>\
**Category:** Help Hub\
**Tags:** tests, package-library\
**Created:** [July 27, 2025, 9:33pm UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901 "2025-07-27T21:33:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devdeer-andrii](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devdeer-andrii](https://community.postman.com/u/devdeer-andrii)\
**Post date:** [July 27, 2025, 9:33pm UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901/1 "2025-07-27T21:33:35Z")

</div>

Hi,

I’m encountering the following runtime error **only** during performance testing:  
`pm.require is not a function`

This does **not** occur during manual request execution.

* * *

### **Context and Setup**

To isolate the issue, I’ve set up a minimal script that uses `pm.require()` to import internal team’s Postman package _(name is changed in the post)_:

**Pre-request Script (on the collection):**

```javascript
pm.request.headers.upsert({ key: 'Before-Require', value: 'test' });

try {
    const package = pm.require('@team/package');
    pm.request.headers.upsert({ key: 'Require-Success', value: 'yes' });
} catch (err) {
    pm.request.headers.upsert({ key: 'Require-Error', value: err.message });
}

pm.request.headers.upsert({ key: 'After-Require', value: 'test' });

```

**Request URL (invalid on purpose to inspect headers in performance test):**

```auto
http://{empty-variable}/

```

* * *

### Observed Behavior

- **Manual execution:**  
The request runs successfully, and the `uuid` module is imported without errors.  

- **Performance test execution:**  
The error `"pm.require is not a function"` is caught and inserted into the request headers.  

Is `pm.require()` unsupported in the performance test runtime environment?  
If so, is there an alternative way to use libraries in performance test scripts?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 28, 2025, 5:53am UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901/2 "2025-07-28T05:53:33Z")

</div>

pm.require() is not supported in the Postman Performance Testing (formerly called “Runner” or “Collection Runner”) runtime environment.

If you want a workaround I will help you

---

<div class="post-metadata">

**Author:** ![devdeer-andrii](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@devdeer-andrii](https://community.postman.com/u/devdeer-andrii)\
**Post date:** [July 28, 2025, 6:10am UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901/3 "2025-07-28T06:10:25Z")

</div>

Thanks for the info. I assume that workaround is inserting implementation of all needed functions at the beginning of the script.

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [July 28, 2025, 6:20am UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901/4 "2025-07-28T06:20:16Z")

</div>

As a workaround, you should directly include any essential utility code or functions within your pre-request or test scripts, rather than importing them as external packages. This means copying and pasting the relevant logic from your internal library into the script so it runs natively in the restricted sandbox. While this approach may not be as modular or maintainable as using packages, it ensures compatibility with the performance test runtime and allows your scripts to execute successfully without dependency errors. For more complex scenarios, consider refactoring your scripts to minimize reliance on external libraries or handle such logic outside of Postman before tests are run.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [July 29, 2025, 2:36pm UTC](https://community.postman.com/t/pm-require-is-not-a-function-error-during-performance-tests/82901/5 "2025-07-29T14:36:41Z")

</div>

You need to be careful with scripting on performance tests, as the scripts still take some time to execute and could potentially skew the results.

I’ve not used the performance tools in Postman to see whether the reports breaks down the run to show any potentially time taken by scripts.

I would still keep code like assertions to a minimum.
