# Unable to launch Newman javascript API run command

**URL:** <https://community.postman.com/t/unable-to-launch-newman-javascript-api-run-command/43738>\
**Category:** Help Hub\
**Tags:** newman-project, tests, collections\
**Created:** [February 8, 2023, 8:05pm UTC](https://community.postman.com/t/unable-to-launch-newman-javascript-api-run-command/43738 "2023-02-08T20:05:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quinnjr](https://avatars.discourse-cdn.com/v4/letter/q/5f8ce5/32.png) [@quinnjr](https://community.postman.com/u/quinnjr)\
**Post date:** [February 8, 2023, 8:05pm UTC](https://community.postman.com/t/unable-to-launch-newman-javascript-api-run-command/43738/1 "2023-02-08T20:05:35Z")

</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_:  
I have a collection that I’m trying to automate as part of launching my company’s API service. Currently the collection works in Postman, but I’m trying to add the automation portion of running it with Newman.

I have a javascript module build that runs the process from what I’ve read in the documentation:

```auto
const main = async () => {
  const regionName = process.env['REGION_NAME'];
  const environment = process.env['ENVIRONMENT'];
  const mfaToken = process.env['MFA_TOKEN'];
  const accessToken = process.env['ACCESS_TOKEN'];
  const userEmail = process.env['USER_EMAIL'];
  const userPassword = process.env['USER_PASSWORD'];

  const config = await buildConfig(regionName, environment);

  const newmanConfig = {
    collection,
    environment: {
      id: "bd5fbe4a-a5af-4536-9e94-7c66a14ec6a5",
      name: config.apiEnvironment,
      values: [
        {
          key: 'itglue',
          value: config.baseUrl,
          enabled: true
        },
        {
          key: "itglue-api",
          value: config.apiUrl,
          enabled: true
        },
        {
          key: 'refresh_subdomain',
          value: config.subdomain,
          enabled: true
        },
        {
          key: 'jwt_subdomain',
          value: config.subdomain,
          enabled: true
        },
        {
          key: 'api-token',
          value: accessToken,
          enabled: true
        },
        {
          key: 'mfa_token',
          value: mfaToken,
          enabled: true
        },
        {
          key: 'user_email',
          value: userEmail,
          enabled: true
        },
        {
          key: 'user_password',
          value: userPassword,
          enabled: true
        }
      ],
      _postman_variable_scope: "environment",
      _postman_exported_at: "2022-08-18T14:38:14.591Z",
      _postman_exported_using: "Postman/9.28.2"
    },
    reporters: ['cli', 'junit'],
    reporter: {
      junit: {
        export: join(
          process.cwd(),
          './resources/reports/it-glue-newman-report.xml'
        )
      }
    }
  }

  newman.run(newmanConfig)
    .on('start', (err, args) => {
      if (err) throw err;
      console.log('======== Run Api Tests... ========')
    })
    .on('done', (err, summary) => {
      if (err) {
        throw err;
      } else if (summary.error) {
        throw summary.error;
      } else {
        console.log(summary.run);
      }
    });
};

```

However, in testing, I can’t get the `start` event to emit. The application completes without executing any of the Newman tests for the API.

I’m kind of stumped as to what is going wrong at this point. Anyone have any thoughts?

 ![Screenshot from 2023-02-08 15-04-54](https://us1.discourse-cdn.com/getpostman/original/3X/c/1/c19a5cab032cc6901cb6cb34ea3285cb514736c5.png)

_How I found the problem_:  
Trying to run Newman with my configuration.

_I’ve already tried_:

- Writing the script as solely CommonJS instead of a ESM Module
- Changing Newman’s import to use CommonJS instead of ESM import
- Using a callback function instead of the EventEmitter events
- Using Newman from the commandline (this works)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 4:43pm UTC](https://community.postman.com/t/unable-to-launch-newman-javascript-api-run-command/43738/2 "2025-04-14T16:43:08Z")

</div>

Closed on April 14, 2025, 4:43pm UTC

Thanks for your post, and sorry we didn’t get to this sooner. This isn’t the experience we want for our users.

Since the post is a bit older, we’re closing it to make room for newer discussions. If you’re still experiencing this or have new details to share, we’d love for you to start a new discussion.
