How to install and run Newman without Command-line

I have Nodejs and npm installed on my computer but command line has been disabled by admin. I can not run any command through command line but can run through batch file. I want to run the postman collection through Newman but not able to install it without command line. I tried to install the Newman using batch file but it is giving error. So can anyone tell me how to run the collection through Newman without installing it?


I can share with you how I do it.

Below is the newman library script I run with node.js
I have some extra packages included.
htmlextra for reporting
env for keeping our api keys and collection id’s out of the script.

If you simply replace the following you don’t need “env”:
{collUID} with the collection uid you want to run
{envID} with the environment id (if you have an environment)
{key} with your postman api key

I would recommend installing the htmlextra package as it’s an amazing reporting tool

If you don’t want to use the postman api you can use the json files (see the commented lines) to run the collection with a given environment. Again, if you have an environment.

const { Console } = require('console');
const newman = require('newman'); // require newman in your project
const key = process.env.postman_api_key;
const collUID = process.env.collUID;
const envID = process.env.envID;

// The signature for the run function is object , callback: function) => run: EventEmitter
        //collection: require('.\\Orders_1.postman_collection.json'),
		collection: `${collUID}?apikey=${key}`,
        //environment: require('.\\localHost.postman_environment.json'),
		environment: `${envID}?apikey=${key}`,
		reporters: ['htmlextra','cli'], 
		{ //Go here for documentation:
			htmlextra: //Report options
				export: '.\\InnovaAPIReport.html', //Directory and name
				template: '.\\InnovaAPITemplate.hbs', //Template used for report. Html, CSS and JS are all embedded.
				title: 'Innovations API',
				showEnvironmentData: true,
				browserTitle: "Innovations API Report",
				showMarkdownLinks: true,                
				showFolderDescription: true,
                skipSensitiveData: true //Hides request header because it can contain the authorization tokens.               
	},// <-- End of options object
	function (err,summary)// <-- Beginning of callback function
		if (err)
			throw err; 
        } else
	}// <-- End of callback	
).on('start', function (err, args) { // <-- start event. 
    	console.log('running a collection...');
}).on('done', function (err, summary) { // <-- done event.
    if (err || summary.error) {
        console.error('\nCollection run encountered an error.');
    else {
        console.log('\nCollection run completed.');

Also, if you have variables you use for things like username and password, or base url, use environment variables as they seem to work the best.

You will still have to “install” newman package in the local directory using the command line, but admin should allow you to install it there.

Also, you’ll need to run the script using the command line with node.

If you can’t use the command line for anything, I don’t think you’ll be able to do it.


I can help you by sharing this link to have an idea how to run a collection on command line with newman @uzairaziz2004

Hey @amenibt

That’s the thing that this user cannot do so I’m not sure that the link really helps in this context. :smiley:

1 Like

ah yes ! thanks @dannydainton