# How to import a library in postman 'tests'?

**URL:** <https://community.postman.com/t/how-to-import-a-library-in-postman-tests/41897>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [December 8, 2022, 8:29pm UTC](https://community.postman.com/t/how-to-import-a-library-in-postman-tests/41897 "2022-12-08T20:29:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaganraj-cohesity](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jaganraj-cohesity](https://community.postman.com/u/jaganraj-cohesity)\
**Post date:** [December 8, 2022, 8:29pm UTC](https://community.postman.com/t/how-to-import-a-library-in-postman-tests/41897/1 "2022-12-08T20:29:07Z")

</div>

Group,  
I am trying to import a library to print current working directory in Postman ‘tests’ section? If I try with the below code

```auto
let process = require('node:process');
current_dir = process.cwd()
console.log('Current directory: ' + current_dir);

```

I get

```auto
There was an error in evaluating the test script: Error: Cannot find module 'node:process'

```

My second doubt is, how do we import a user define library file? (Use case, I would like declare JSON schema variables in one file and have that used in all Postman tests by importing this JSON schema file)

Thanks in advance for the responses.

---

<div class="post-metadata">

**Author:** ![Corral](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/corral/32/13988_2.png) [@Corral](https://community.postman.com/u/Corral)\
**Post date:** [December 14, 2022, 8:18pm UTC](https://community.postman.com/t/how-to-import-a-library-in-postman-tests/41897/2 "2022-12-14T20:18:29Z")

</div>

The common trick for declaring a JavaScript library to Postman is to include it¡s whole JS code as a giant global variable. There are some blogs describing this technique:

> **[postman-util-lib](https://joolfe.github.io/postman-util-lib/)**
>
> :rocket: A crypto utility library to be used from Postman Pre-request and Tests script tabs.

> **[Adding External Libraries in Postman | Postman Blog](https://blog.postman.com/adding-external-libraries-in-postman/)**
>
> Learn how to use the libraries included in the Postman sandbox, then review some methods for adding your own external libraries.

Hope it helps,  
Mariano Corral
