Using a package from a second package

I have created two packages. Let’s call them β€˜a’ and β€˜b’ for my team β€˜t’.

In package b I would like to call myFunction from package a.

I have tried the following:

// package b
const a = pm.require('@t/a');

function mySecondFunction() {
   a.myfunction();
}

module.exports = { mySecondFunction };

When I try to use package b in a request script I get the following error:

Error in package '@t/b': Cannot find module '@t/a'

Is this supported? If yes, how should I change my code in package b so I can call functions from package a?

Hey @tibiextera :wave:t2:

Referencing packages inside other packages is not currently supported.

Could you explain more about your use case and the need to use a script in this way? It will help us to better understand your requirement.

I am creating tests for the current REST API that I am working on. Some tests require that I invoke the REST API with other calls than the main request to set up the data that the main request will use for the test.

I created a package that turns the pm.sendRequest function into an async function that returns a Promise.

I was planning to use this in a package that is specific for this current API, while still having it available for other APIs that I might build in the future.

That led to requiring a package from a second package, which, after some more research, seems that it is not possible currently.