'newman' is not recognized as an internal or external command in TeamCity Step Build

I am trying to run newman as command line script as step in Teamcity

I am following this example for my work

I am getting below error . Note . I already installed which available in C:\Users\kalai\AppData\Roaming\npm for my local machine .

I am able to run successfully below command from command line but not in inside teamcity build
newman run “https://www.getpostman.com/collections/8ea32a998d359102a156

‘newman’ is not recognized as an internal or external command,*

operable program or batch file.*

Process exited with code 1*

Process exited with code 1 (Step: Command Line)*

Could you please help to resolve this issue . Thank you for looking at this question

1 Like

Hi @m.semalaiappan,

Welcome to the Postman community ! Just wanted to check with you whether you have installed newman after installing npm because although newman is part of the npm registry, you would have to go ahead and install newman on your machine using the following command:

npm install -g newman

I think the following documentation would be helpful: https://www.npmjs.com/package/newman

1 Like

Hi,

I am trying to use self-hosted agent in Azure DevOps to run Postman tests. Due some restrictions to use extra tools, I am using command prompt to install and run newman under Microsoft Windows server based private agent.

My configuration in Azure DevOps pipeline

  1. Command line
    npm install -g newman
    -> Installation working fine

  2. Command line
    newman run …

What I am getting error is ‘‘newman’ is not recognized as an internal or external command,…’

The same tasks works fine with hosted agent. I suppose setting up the right path for newman is the problem. But I can’t make it solved with setting up global PATH or installing in local. Can you someone help me on this.

BR,
Shanmugam

1 Like

Btw, I followed these steps while setting up the tests under Azure DevOps: https://medium.com/@ganeshsirsi/how-to-configure-postman-newman-api-tests-in-azure-devops-or-tfs-and-publish-html-results-caf60a25c8b9

1 Like

I am having the same issue as shanchin2k

Hi @alessio.mazzone,

Welcome to the community. :wave:

Basically, the error message that you are seeing occurs when Windows is not able to find out where Newman is installed.

This can be fixed by adding the npm global install target directory to the system path, as below and this needs to be run in an administrative command prompt.

setx /M PATH %AppData%\npm

Thanks @suraj.purohit for the response. This is tested and works.

One question:
I see the NPM path is set based on currently logged in user’s path during this setx command run. It is problematic in our case since it should not point any real user’s folder since users can be removed and new users added. Can’t we set this some other way to point some user-independent folder? Any way to install the package in a user-independent folder?

Creating a separate user for this? Any other option to set other folder as installation path?

Hi, I am getting the similar issue
I am trying to run postman tests on Teamcity server. I followed this link for setup https://medium.com/@vdespa/how-to-run-postman-newman-tests-in-teamcity-9d767c7de542 Although I have installed node, npm and newman -g. When I run from TeamCity “Command line build step” it doesn’t recognize newman command

Shows that I have newman installed

Teamcity build CLI error

As you can see in the step 2, I am just running the command $ newman --version ,but it is exited with code 0. Probably, it is not able to find where newman is installed? I also tried this $setx /M PATH %AppData%\npm but still doesn’t work

In Teamcity server, I also tried running running newman from the directory where my tests are located it shows ‘node’ is not recognized. However, I tried running the tests on my local desktop, I can run the tests from tests directory but that approach wouldn’t work in TeamCity since it shouldn’t be absolute path for location of the tests. But at least in my local desktop I can newman run from the absolute path where my tests are located

C:\Users\user\source\repos\AutoTests>newman run APIAutoTests.postman_collection.json --environment ApiProtest.postman_environment.json

Any help would be very appreciated.

I was able to resolve the issue by installing newman in C:\npm folder instead of under any system folder. Also before I wasn’t resetting the npm Config to default which I did this time. I am able to run my tests now.

Detailed Steps to install nodejs, npm and newman on teamcity server

  1. Login to TeamCity Server

  2. Download the Nodejs

  3. Install Nodejs (C:\ProgramFiles\nodejs)

  4. Open Command prompt as run as Administrator

  5. type node -v (should return node version)

  6. type npm - v (should return npm version)

  7. type npm prefix -g (usually it defaults to user folder and returns

  8. C:\Users\user1\AppData\Roaming\npm )

  9. Note the current global prefix

  10. Set the global prefix to: npm config set prefix C:\npm

  11. Install the needed packages: npm install -g newman

  12. Restore the prefix to the previous value npm config set prefix

  13. C:\Users\user1\AppData\Roaming\npm

  14. Open System Environment variables

  15. Edit environment variables and make sure this added: C:\npm

  16. Also additionally you can check under user variables for user1 Path

  17. is set to for npm: C:\Users\user1\AppData\Roaming\npm

  18. Now restart the windows server machine

  19. After that from the Teamcity web interface, restart the teamcity

  20. server

You should have running newman on your teamcity server.

1 Like

Hi @suraj.purohit,
I’m getting newman is not recongnized even after doing this step. I followed below site for the build pipeline

Kindly help in this regard.