Error: Cannot find module 'newman' Require stack:

Hi Everyone,

I just installed newman and able to run postman-collection test cases with the command line.
However, when I try to create NodeJs script the following statement
const newman = require(‘newman’); // require newman in your project
throws exception
Error: Cannot find module ‘newman’
Require stack:

I am not sure how to fix this problem. Any help is appreciated.

JDang

Hey @jdang

Welcome to the community!! :star:

Do you have a package.json file with Newman as one of the dependencies?

If you have that in place in the same directory as the script, you can use the npm i -S newman to install the node_modules.

Once that’s been installed, you should be able to run the script again.

1 Like

Thanks, I need to have package.json then install newman locally.

1 Like

If you have installed newman globally and you get the error “Error: Cannot find module ‘newman’” , probably your NODE_PATH is misconfigured.

Please check the following link to get this fixed: https://stackoverflow.com/a/14515868/766177

2 Likes