Error: Cannot find package in eval statement

For testing purposes I created a simple Package Library named logger:

function logger() {

module.exports = {

Then, I tried using it in a eval statement in pre-script of a request:

const { logger } = pm.require("@my-domain/logger"); logger();

Package libraries seem not to work in eval statements and I got the following error:

“Error: Cannot find package ‘@my-domain/logger’”

Do you plan to fix this?

Why would you need to use EVAL?

The whole point of the new package manager is that you can call the functions directly after including the package with a “pm.requires” statement.

Reuse scripts in Postman | Postman Learning Center

I’m not a JavaScript expert and I might be missing something but I thought one of the points of the new package manager was to then avoid using EVAL which isn’t a recommended method for importing functions.

1 Like

Hi :slight_smile: Thank you for your reply :slight_smile:

I know that the new package manager was introduced to avoid using eval and make it possible to share functions between different scripts in Postman.

The thing is that this feature was introduced just recently and I have been sharing code in Postman using eval so far. I use eval at the start of my collections’ runs so my requests have access to reusable code, which is sorted into different folders and requests. I wanted to try the new feature and moved some of my functions to package library but because of that my collection stopped working completely.

It would be difficult for me to change my code at once to stop using eval at all. I really would like to try this feature because when using eval I have to remember to pass pm and Postman objects to some of my functions and I do not get some editor prompts/hints but I am not sure if package library would suit my needs for all cases in which I reuse my code.

Making package libraries usable in eval statements would make switching to the new feature smoother and easier for people who already have developed collections and used eval to share code so far.