# Using envVar property in node.js script when using newman as library

**URL:** <https://community.postman.com/t/using-envvar-property-in-node-js-script-when-using-newman-as-library/31153>\
**Category:** Help Hub\
**Tags:** newman-project, variables\
**Created:** [December 30, 2021, 5:32pm UTC](https://community.postman.com/t/using-envvar-property-in-node-js-script-when-using-newman-as-library/31153 "2021-12-30T17:32:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizjiang55](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@lizjiang55](https://community.postman.com/u/lizjiang55)\
**Post date:** [December 30, 2021, 5:32pm UTC](https://community.postman.com/t/using-envvar-property-in-node-js-script-when-using-newman-as-library/31153/1 "2021-12-30T17:32:41Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

_My question_:  
Hi I tried to pass some environment variable via command line to my node.js + newman script. But didn’t get it working, could someone please help me here?

_Details (like screenshots)_:

My run.js as below

```auto
const newman = require('newman');
const appName = process.env.NAME;
const fileName= `../collection/${appName}-collection.json`

var options ={
collection: require(`${fileName}`),
envrionment: envrionmnet.get(),
reporters:'cli',
   envVar​: ​[​ 
      {​ ​
         "key"​:​"env"​,​ ​
         "value"​:​`​${​process​.​env​.​ENV​}​`​
      }​,
      {​ ​
         "key"​:​"country"​,​ ​
         "value"​:​`​${​process​.​env​.​COUNTRY​}​`​
      }​,
  ​ ]​
}

newman.run(options, function(err,summary){
}

```

where I try to pass the variable in the command line:  
NAME=abc ENV=qa COUNTRY=us node scr/run.js  
but the environment.json seems not to take these two variables

---

<div class="post-metadata">

**Author:** ![maintenance-speciali](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@maintenance-speciali](https://community.postman.com/u/maintenance-speciali)\
**Post date:** [August 2, 2022, 8:17pm UTC](https://community.postman.com/t/using-envvar-property-in-node-js-script-when-using-newman-as-library/31153/2 "2022-08-02T20:17:57Z")

</div>

It appears that you are setting up the envVar array correctly. (I recently just had to figure this out for myself, though I was pulling my arguments out of `process.argv[]`). I leaned on console.log to verify what I was passing into `newman.run()`.

I’m running newman 5.3.2
