首页 > 解决方案 > 在 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

我在这里想念什么?

标签: node.jsubuntunpmpostmannewman

解决方案


问题出在节点版本上。我的 ubuntu 机器正在安装一个古老版本的节点。一旦我得到 v12.* ,问题就解决了。


推荐阅读