admin管理员组文章数量:1307625
I installed "newman" package on my puter globally and able to run newman on the mand line
npm install -g newman
However, I need to run my test collections in nodejs script and the following statement throws an exception
Cannot find module 'newman' Require stack:
const newman = require('newman');
Any ideas to fix this problem?
Austin
// this is full error stack
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'newman'
Require stack:
- C:\xxx\postman-tests\parallel.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\xxx\postman-tests\parallel.js:8:16)
at Module._pile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\xxx\\postman-tests\\parallel.js'
]
}
I installed "newman" package on my puter globally and able to run newman on the mand line
npm install -g newman
However, I need to run my test collections in nodejs script and the following statement throws an exception
Cannot find module 'newman' Require stack:
const newman = require('newman');
Any ideas to fix this problem?
Austin
// this is full error stack
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'newman'
Require stack:
- C:\xxx\postman-tests\parallel.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\xxx\postman-tests\parallel.js:8:16)
at Module._pile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\xxx\\postman-tests\\parallel.js'
]
}
Share
Improve this question
edited Nov 1, 2019 at 21:10
AustinTX
asked Nov 1, 2019 at 20:48
AustinTXAustinTX
1,3525 gold badges23 silver badges28 bronze badges
4
- Could you post the full error? – Ömürcan Cengiz Commented Nov 1, 2019 at 20:53
- Just updated the question with full error stack – AustinTX Commented Nov 1, 2019 at 21:12
-
2
You would need to create a
package.json
file and save Newman as one of the dependencies before running the script – Danny Dainton Commented Nov 1, 2019 at 21:26 - This works, I was confused about the global package. I need to install it locally too. – AustinTX Commented Nov 3, 2019 at 14:41
1 Answer
Reset to default 7you have installed newman
package globally. In order to use it in your project you need to install it locally in your project. If your project does not have a package.json
file you can init it by running npm init
in the root directory of your project. After that you can install the package by npm install newman
to add it to your dependencies. Now the package can be required within your project.
本文标签: javascriptCannot find module 39newman39 Require stackStack Overflow
版权声明:本文标题:javascript - Cannot find module 'newman' Require stack: - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741840874a2400489.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论