You’re using a deprecated API here, that was actually changed many major versions ago.
You should really be using pm.environment.set() instead of that older syntax.
Over the next couple of major versions, these older APIs and functions will stop working. Although this will still work now, I advise you to change this syntax in your scripts.