node.js - 在 ubuntu 上运行 newman 时出现语法错误
问题描述
我是纽曼的新手。我导出了我的 collection.json 和 env.json,并试图与我的 CI\CD 管道(在本例中为 vsts)集成。我有两个任务 - 安装 newman 然后运行测试。Newman 安装工作正常,但运行测试的任务因语法错误而失败。
newman run Dev-.postman_collection.json -e Dev.postman_environment.json
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /vsts/agent/_work/_temp/5260102a-45bf-435f-814a-110329173b47.sh
/usr/local/lib/node_modules/newman/bin/newman.js:7
{ Command } = require('commander'),
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
安装步骤 -
apt update
apt-get update
apt-get install nodejs
apt-get install npm
npm install -g newman
节点版本 = v4.2.6
纽曼版本 = newman@5.1.2
操作系统 = Ubuntu
我在这里想念什么?
解决方案
问题出在节点版本上。我的 ubuntu 机器正在安装一个古老版本的节点。一旦我得到 v12.* ,问题就解决了。
推荐阅读
- java - 使用 Selenium WebDriver 阻止登录
- elasticsearch - 是否可以将任务 create_snapshot 的优先级从 NORMAL 更改为 HIGH 或 URGENT?
- node.js - 将 Jira 的 REST API 与节点一起使用
- javascript - 我应该使用顺序承诺还是 Promise.all
- python - 如何将字符串拆分为字符并用浮点值替换字符以在 Python 中找到原始字符串的总和?
- python - SymPy 多项式除法返回意外结果
- javascript - 使用 javascript 设置跨域 cookie
- html - 如何将导航栏分成同一行的两个部分?
- webrtc - webAudio - webRTC echoCancellation 约束似乎不起作用
- python - 将torchaudio加载的16位音频从`float32`截断到`float16`是否安全?