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:
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
Command line
npm install -g newman
-> Installation working fine
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.
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.
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?
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
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
Login to TeamCity Server
Download the Nodejs
Install Nodejs (C:\ProgramFiles\nodejs)
Open Command prompt as run as Administrator
type node -v (should return node version)
type npm - v (should return npm version)
type npm prefix -g (usually it defaults to user folder and returns
C:\Users\user1\AppData\Roaming\npm )
Note the current global prefix
Set the global prefix to: npm config set prefix C:\npm
Install the needed packages: npm install -g newman
Restore the prefix to the previous value npm config set prefix
C:\Users\user1\AppData\Roaming\npm
Open System Environment variables
Edit environment variables and make sure this added: C:\npm
Also additionally you can check under user variables for user1 Path
is set to for npm: C:\Users\user1\AppData\Roaming\npm
Now restart the windows server machine
After that from the Teamcity web interface, restart the teamcity
server
You should have running newman on your teamcity server.