Newman doesn't seem to like code libraries set in globals

Hello, I use collection runner in my daily job but as postman have recently done a shake up and locked the collection runner behind a higher paywall I was suggested by support to run my collections through postman CLI or newman… due to security protocols in my company blocking postman CLI i install newman instead.

I can’t seem to get my collections running with all of my code though, let me try to briefly explain what happens in my collection runs.

I have a library of functions saved to my global, this is code that does things with variables that come in from a csv files in the pre-req eg. takes partial postcodes and turns them into full postcodes then saves them to globals for use in the requests… then i have code in the test script section that builds tests based on variables that come through on the csv… this all works fine on postman itself.

so in that second example the code in my tests section is just this:

const lib = eval(globals.loadLib);

lib.jsonOrXML();

lib.tests();

it then uses these functions that have been eval’d from globals, to build all the tests needed at run time.

In newman i have downloaded the collection.JSON and the globals.JSON and provide it with the csv needed… here is the command i run:

newman run “BG.JSON” -d “BG.CSV” -g “globals.JSON”

but it doesn’t seem to be able to see my lib from the globals… i get type errors saying the following:

Cannot read properties of undefined (reading ‘jsonOrXML’)
iteration: 110 at test-script

if i comment out the jsonOrXML function, it then has the same error but for “tests”…

this says to me its not able to read the functions saved on the lib constant… am i doing something wrong here? sorry if its not explained very well, i can answer further questions