gpt4 book ai didi

javascript - 找不到模块 'newman' 需要堆栈 :

转载 作者:行者123 更新时间:2023-11-30 13:49:03 26 4
gpt4 key购买 nike

我在我的计算机上全局安装了“newman”包并且能够在命令行上运行 newman

npm install -g newman 

但是,我需要在 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'
]
}

最佳答案

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

关于javascript - 找不到模块 'newman' 需要堆栈 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58665717/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com