【问题标题】:Getting syntax error while running newman on ubuntu在 ubuntu 上运行 newman 时出现语法错误
【发布时间】:2020-12-06 11:57:43
【问题描述】:

我是纽曼的新手。我导出了我的 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

os = ubuntu

我在这里错过了什么?

【问题讨论】:

  • 集合文件名中的“-”看起来很可疑。也许这是一个错字?另外,我总是在文件名/路径周围加上引号。

标签: node.js ubuntu npm postman newman


【解决方案1】:

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

【讨论】:

  • 只需几个步骤: 1. 使用nvm ls 查找最新版本。 2.安装最新版本。 3. 再次安装newman
猜你喜欢
  • 2017-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多