Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 找不到模块';纽曼&x27;需要堆栈:_Javascript_Node.js_Postman_Newman - Fatal编程技术网

Javascript 找不到模块';纽曼&x27;需要堆栈:

Javascript 找不到模块';纽曼&x27;需要堆栈:,javascript,node.js,postman,newman,Javascript,Node.js,Postman,Newman,我在全球计算机上安装了“newman”软件包,并且能够在命令行上运行newman npm安装-g纽曼 但是,我需要在nodejs脚本中运行我的测试集合,下面的语句抛出一个异常 找不到模块“newman”要求堆栈: const newman=require('newman'); 有什么办法解决这个问题吗 奥斯汀 // this is full error stack internal/modules/cjs/loader.js:797 throw err; ^ Error:

我在全球计算机上安装了“newman”软件包,并且能够在命令行上运行newman

npm安装-g纽曼
但是,我需要在nodejs脚本中运行我的测试集合,下面的语句抛出一个异常

找不到模块“newman”要求堆栈:

const newman=require('newman');
有什么办法解决这个问题吗

奥斯汀

// 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._compile (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'
  ]
}
//这是完整的错误堆栈
内部/modules/cjs/loader.js:797
犯错误;
^
错误:找不到模块“newman”
需要堆栈:
-C:\xxx\postman tests\parallel.js
在Function.Module.\u解析文件名(internal/modules/cjs/loader.js:794:15)
at Function.Module._load(内部/modules/cjs/loader.js:687:27)
at Module.require(内部/modules/cjs/loader.js:849:19)
根据需要(internal/modules/cjs/helpers.js:74:18)
反对。(C:\xxx\postman tests\parallel.js:8:16)
at模块编译(内部/modules/cjs/loader.js:956:30)
在Object.Module._extensions..js(internal/modules/cjs/loader.js:973:10)
在Module.load(内部/modules/cjs/loader.js:812:32)
at Function.Module._load(内部/modules/cjs/loader.js:724:14)
位于Function.Module.runMain(internal/modules/cjs/loader.js:1025:10){
代码:“未找到模块”,
requireStack:[
'C:\\xxx\\postman tests\\parallel.js'
]
}

您已经在全球范围内安装了
newman
软件包。为了在项目中使用它,您需要在项目中本地安装它。如果您的项目没有
package.json
文件,您可以通过在项目的根目录中运行
npm init
来初始化它。之后,您可以通过
npm install newman
安装软件包,将其添加到依赖项中。现在,您的项目中可能需要该包。

您可以发布完整错误吗?刚刚用完整错误堆栈更新了问题。您需要创建一个
package.json
文件,并将Newman保存为依赖项之一,然后再运行脚本。在运行该脚本之前,我对全局包感到困惑。我也需要在本地安装。我在评论中说的。你应该接受这个答案,这是有效的,我对全球方案感到困惑。我也需要在本地安装它。