# Can we get the common JS functions from GIT or from a network path to Postman pre/post script

**URL:** <https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360>\
**Category:** Learning Lab\
**Tags:** tests, scripts, package-library\
**Created:** [October 8, 2025, 2:37pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360 "2025-10-08T14:37:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 2:37pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/1 "2025-10-08T14:37:06Z")

</div>

Hi

Is there a way to use the Common JS functions from a GIT repo or from a Network path within Postman pre request script/Post request script.

Thank you

Kavitha

---

<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 8, 2025, 2:51pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/2 "2025-10-08T14:51:59Z")

</div>

Hey @kdayalan 👋

Could you provide an example of these common JS functions?

Would you like to have a single script, with different functions, that can be required and used within your scripts at the Collection/Folder/Request level?

Postman has a [Package Library](https://learning.postman.com/docs/tests-and-scripts/write-scripts/packages/package-library/) that will give you this functionality:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/7/d70314f23eed4a5c5424a77762fad1f1183d16f1.png)

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 2:56pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/3 "2025-10-08T14:56:47Z")

</div>

Yes Single script with custom JS functions which has our business logic/complex calculations but we wanted to maintain outside the postman and retrieve it within postman script inside the Package some thing like a JAVA libraries but not all functions will be used , we use what we needed for the specific collection/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 8, 2025, 3:04pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/4 "2025-10-08T15:04:27Z")

</div>

The Package Library lives inside Postman, that way it’s able to call these functions if Collections are run outside of the Platform, like with the Postman CLI.

You can use [external packages](https://learning.postman.com/docs/tests-and-scripts/write-scripts/packages/external-package-registries/) in the scripts from NPM or JSR but those would be public packages so likely not what you required.

[Private packages](https://learning.postman.com/docs/tests-and-scripts/write-scripts/packages/external-package-registries/#import-a-private-package) can be used but this functionality is not available on all plans.

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 3:10pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/5 "2025-10-08T15:10:47Z")

</div>

We have enterprise plan with alle carte do we have Private Packages features to be used?

Thank you

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 3:17pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/6 "2025-10-08T15:17:19Z")

</div>

Also one more question/confirmation when using the Collection id/env id /collection name using Postman CLI or Newman CLI inside CI pipeline would a Postman API call will happen for both or happens only for Newman and will be coming under 1,000,000 calls per month?

pm.require will it work both in newman and postman cli execution or will work only in Postman cli

---

<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 8, 2025, 3:30pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/7 "2025-10-08T15:30:13Z")

</div>

I’m not sure that I fully understand that question - Are you using the Newman or the Postman CLI.

Just to note, the packages would only be available to use with the Postman CLI.

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 3:31pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/8 "2025-10-08T15:31:18Z")

</div>

Got it , so if we are using external packages it will work only in Postman CLI? not in newman CLI

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 8, 2025, 3:33pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/9 "2025-10-08T15:33:03Z")

</div>

I am checking if we use Newman/postman cli for CI pipeline using collection id /collection name without package library both calls Postma API to retrieve remotely is that correct?

---

<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 8, 2025, 4:34pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/10 "2025-10-08T16:34:21Z")

</div>

They work in different ways - To directly use the collection or environment ids, you would need to be using the [Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-options/) and using your Postman API Key, if this is running in a pipeline.

You wouldn’t be able to do that with Newman, you would only be able to use an exported Collection file or the [Postman API URL](https://learning.postman.com/docs/collections/using-newman-cli/continuous-integration/#run-a-collection-using-newman-and-the-postman-api) which fetches the Collection.

Are you using one of the tools or both of them? I’m a bit confused 😃

I’d need more information about the way you use it now and an example of the script, to provide more details. 🙏

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 9, 2025, 3:44pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/11 "2025-10-09T15:44:18Z")

</div>

We are in exploration stage so looking for optimal solution thats the reason asking for both the ways to run in CI Pipeline using Postman CLi and Newman CLI which serves our need the best

---

<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 9, 2025, 3:54pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/12 "2025-10-09T15:54:21Z")

</div>

I would recommend using the Postman CLI in almost every case. It always includes the latest features from Postman, so anything you use, such as the Package Library, will work as expected when run in your pipeline.

Another advantage of the Postman CLI is that it integrates directly with your Collections in the UI. This lets you view the history of your runs and compare results easily.

While the Postman CLI doesn’t provide some of the custom reporting options or the ability to use it as a library within a project, those limitations are minor. If your Collection uses newer features and functionality, those wouldn’t run properly outside the CLI anyway.

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 9, 2025, 3:55pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/13 "2025-10-09T15:55:31Z")

</div>

Hi Danny

Request information you said we can use private npm packages in the pre request script.

But when I tried the example package you said in of your previous community response.

pm.require(‘@npm/crypto-js@4.2.0’) it didnt work, how to get it work

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 9, 2025, 3:56pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/14 "2025-10-09T15:56:34Z")

</div>

Yes we are mostly leaning towards to Postman CLI , will check the challenges when we try to implement. thank you

---

<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 9, 2025, 3:58pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/15 "2025-10-09T15:58:57Z")

</div>

It looks like they syntax you’re using isn’t correct here, it should be this for the package you mentioned:

```auto
const cryptoJs = pm.require('npm:crypto-js@4.2.0');

```

---

<div class="post-metadata">

**Author:** ![kdayalan](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kdayalan](https://community.postman.com/u/kdayalan)\
**Post date:** [October 9, 2025, 4:09pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/16 "2025-10-09T16:09:30Z")

</div>

> [@danny-dainton](#):
>
> `const cryptoJs = pm.require('npm:crypto-js@4.2.0');`

ok below is my code referring to deprecated cryptoJS what is the new code to achieve the same functionality , I tried different ways but it said not working.

```auto
 var bytes = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(CryptoJS.enc.Utf8.parse(message),CryptoJS.enc.Base64.parse(secretKey)));

```

---

<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 9, 2025, 4:50pm UTC](https://community.postman.com/t/can-we-get-the-common-js-functions-from-git-or-from-a-network-path-to-postman-pre-post-script/85360/17 "2025-10-09T16:50:44Z")

</div>

There was a similar topic raised around this subject, I’m not going to claim to be an expert with that library 😅 but I had a go at trying to answer the question.

Maybe something in that thread might help you out here? 🙏

> [@Replacing crypto-js with the global crypto object](https://community.postman.com/t/replacing-crypto-js-with-the-global-crypto-object/78377/2):
>
> Hey @jimjonah waving_hand Welcome to the Postman Community! postman Although the library is deprecated, it’s not going to be going away soon so you’re ok to still use that. We have also [just released a new feature](https://github.com/postmanlabs/postman-app-support/issues/13542), in the latest version that allows you to use external packages in the sandbox - you should be able to modify your script to this: const crypto = pm.require('npm:crypto-js@4.2.0') For example: const crypto = pm.require('npm:crypto-js@4.2.0'); // Encrypt var ciphertext = cryp…
