AzureDevOps 管道 - Nightwatch selenium 独立安装问题 - 无法 运行 npm 运行 'e2e-setup'(包含 'selenium-standalone install')

AzureDevOps pipeline - Nightwatch selenium standalone installation issue - Unable to run npm run 'e2e-setup' (contains 'selenium-standalone install')

我正在尝试使用各种浏览器设置 selenium 独立服务器脚本在我的本地机器上工作正常但同样在使用 Azure DevOps 工具在 Azure 云上工作时遇到问题。

从日志中(最后的详细日志)我看到以下内容但不确定如何修复它:

2020-04-17T21:39:25.3581171Z Usage: selenium-standalone action [options]
2020-04-17T21:39:25.3581533Z 
2020-04-17T21:39:25.3582171Z npm ERR! Linux 5.0.0-1031-azure
2020-04-17T21:39:25.3582843Z npm ERR! argv "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/node" "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm" "run" "e2e-setup"
2020-04-17T21:39:25.3583217Z npm ERR! node v6.17.1
2020-04-17T21:39:25.3583400Z npm ERR! npm  v3.10.10
2020-04-17T21:39:25.3583580Z npm ERR! code ELIFECYCLE
2020-04-17T21:39:25.3584038Z npm ERR! temp@1.0.0 e2e-setup: `selenium-standalone install`
2020-04-17T21:39:25.3584332Z npm ERR! Exit status 255

我有以下 package.json:

{
  "name": "temp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "nightwatch",
    "e2e-setup": "selenium-standalone install"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/preset-env": "^7.9.0",
    "babel-core": "^6.26.3",
    "babel-plugin-add-module-exports": "^1.0.2",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.24.1",
    "gulp-babel": "^8.0.0-beta.2",
    "selenium-standalone": "^6.17.0"
  },
  "dependencies": {
    "easy-soap-request": "^3.2.2",
    "nightwatch": "^1.3.4",
    "xmldom": "^0.3.0"
  }
}

在 VScode 当我 运行 npm 安装守夜人 npm 安装 selenium-standalone 和 npm 运行 e2e-setup

当我在我的机器上尝试上述操作时,我没有遇到任何问题 - Selenium 服务器 jar 和所有浏览器(chrome、firefox,即 edge)二进制文件正在下载)

以上设置如官方seleinum-standalone npm网站所述(https://www.npmjs.com/package/selenium-standalone#install--run)

我的 Azure CI 设置:

但是当我在 Azure DevOps 工具上尝试同样的操作时(运行 在 Azure 云上也是如此)我遇到了如下问题:

2020-04-17T21:39:22.1913471Z ##[section]Starting: npm run e2e-setup
2020-04-17T21:39:22.1923363Z ==============================================================================
2020-04-17T21:39:22.1923659Z Task         : npm
2020-04-17T21:39:22.1924046Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2020-04-17T21:39:22.1924428Z Version      : 1.166.1
2020-04-17T21:39:22.1924652Z Author       : Microsoft Corporation
2020-04-17T21:39:22.1924983Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
2020-04-17T21:39:22.1925348Z ==============================================================================
2020-04-17T21:39:22.5235427Z SYSTEMVSSCONNECTION exists true
2020-04-17T21:39:22.7105531Z SYSTEMVSSCONNECTION exists true
2020-04-17T21:39:22.7890296Z [command]/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm --version
2020-04-17T21:39:23.0268360Z 3.10.10
2020-04-17T21:39:23.9587311Z [command]/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm config list
2020-04-17T21:39:24.4295571Z ; cli configs
2020-04-17T21:39:24.4297644Z user-agent = "npm/3.10.10 node/v6.17.1 linux x64"
2020-04-17T21:39:24.4298039Z 
2020-04-17T21:39:24.4298357Z ; environment configs
2020-04-17T21:39:24.4298785Z userconfig = "/vsts/agent/_work/_temp/npm/830.npmrc"
2020-04-17T21:39:24.4299106Z 
2020-04-17T21:39:24.4299481Z ; node bin location = /vsts/agent/_work/_tool/node/6.17.1/x64/bin/node
2020-04-17T21:39:24.4300000Z ; cwd = /vsts/agent/_work/r2/a/_QA_IDLookUp
2020-04-17T21:39:24.4300385Z ; HOME = /root
2020-04-17T21:39:24.4301230Z ; "npm config ls -l" to show all defaults.
2020-04-17T21:39:24.4301526Z 
2020-04-17T21:39:24.4304850Z [command]/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm run e2e-setup
2020-04-17T21:39:25.3579514Z not found: java
2020-04-17T21:39:25.3579860Z 
2020-04-17T21:39:25.3581171Z Usage: selenium-standalone action [options]
2020-04-17T21:39:25.3581533Z 
2020-04-17T21:39:25.3582171Z npm ERR! Linux 5.0.0-1031-azure
2020-04-17T21:39:25.3582843Z npm ERR! argv "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/node" "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm" "run" "e2e-setup"
2020-04-17T21:39:25.3583217Z npm ERR! node v6.17.1
2020-04-17T21:39:25.3583400Z npm ERR! npm  v3.10.10
2020-04-17T21:39:25.3583580Z npm ERR! code ELIFECYCLE
2020-04-17T21:39:25.3584038Z npm ERR! temp@1.0.0 e2e-setup: `selenium-standalone install`
2020-04-17T21:39:25.3584332Z npm ERR! Exit status 255
2020-04-17T21:39:25.3584511Z npm ERR! 
2020-04-17T21:39:25.3584965Z npm ERR! Failed at the temp@1.0.0 e2e-setup script 'selenium-standalone install'.
2020-04-17T21:39:25.3585333Z npm ERR! Make sure you have the latest version of node.js and npm installed.
2020-04-17T21:39:25.3585684Z npm ERR! If you do, this is most likely a problem with the temp package,
2020-04-17T21:39:25.3585947Z npm ERR! not with npm itself.
2020-04-17T21:39:25.3586231Z npm ERR! Tell the author that this fails on your system:
2020-04-17T21:39:25.3586678Z npm ERR!     selenium-standalone install
2020-04-17T21:39:25.3587020Z npm ERR! You can get information on how to open an issue for this project with:
2020-04-17T21:39:25.3587342Z npm ERR!     npm bugs temp
2020-04-17T21:39:25.3587803Z npm ERR! Or if that isn't available, you can get their info via:
2020-04-17T21:39:25.3588109Z npm ERR!     npm owner ls temp
2020-04-17T21:39:25.3588351Z npm ERR! There is likely additional logging output above.
2020-04-17T21:39:25.3588530Z 
2020-04-17T21:39:25.3588791Z npm ERR! Please include the following file with any support request:
2020-04-17T21:39:25.3589311Z npm ERR!     /vsts/agent/_work/r2/a/_QA_IDLookUp/npm-debug.log
2020-04-17T21:39:25.3590596Z > temp@1.0.0 e2e-setup /vsts/agent/_work/r2/a/_QA_IDLookUp
2020-04-17T21:39:25.3591763Z > selenium-standalone install
2020-04-17T21:39:25.3592087Z 
2020-04-17T21:39:25.3734932Z Found npm debug log, make sure the path matches with the one in npm's output: /vsts/agent/_work/r2/a/_QA_IDLookUp/npm-debug.log
2020-04-17T21:39:25.3735698Z 0 info it worked if it ends with ok
2020-04-17T21:39:25.3737184Z 1 verbose cli [ '/vsts/agent/_work/_tool/node/6.17.1/x64/bin/node',
2020-04-17T21:39:25.3738213Z 1 verbose cli   '/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm',
2020-04-17T21:39:25.3739010Z 1 verbose cli   'run',
2020-04-17T21:39:25.3739677Z 1 verbose cli   'e2e-setup' ]
2020-04-17T21:39:25.3740072Z 2 info using npm@3.10.10
2020-04-17T21:39:25.3740401Z 3 info using node@v6.17.1
2020-04-17T21:39:25.3741309Z 4 verbose run-script [ 'pree2e-setup', 'e2e-setup', 'poste2e-setup' ]
2020-04-17T21:39:25.3742292Z 5 info lifecycle temp@1.0.0~pree2e-setup: temp@1.0.0
2020-04-17T21:39:25.3743416Z 6 silly lifecycle temp@1.0.0~pree2e-setup: no script for pree2e-setup, continuing
2020-04-17T21:39:25.3744395Z 7 info lifecycle temp@1.0.0~e2e-setup: temp@1.0.0
2020-04-17T21:39:25.3745399Z 8 verbose lifecycle temp@1.0.0~e2e-setup: unsafe-perm in lifecycle true
2020-04-17T21:39:25.3747409Z 9 verbose lifecycle temp@1.0.0~e2e-setup: PATH: /vsts/agent/_work/_tool/node/6.17.1/x64/lib/node_modules/npm/bin/node-gyp-bin:/vsts/agent/_work/r2/a/_QA_IDLookUp/node_modules/.bin:/vsts/agent/_work/_tool/node/6.17.1/x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2020-04-17T21:39:25.3749200Z 10 verbose lifecycle temp@1.0.0~e2e-setup: CWD: /vsts/agent/_work/r2/a/_QA_IDLookUp
2020-04-17T21:39:25.3750457Z 11 silly lifecycle temp@1.0.0~e2e-setup: Args: [ '-c', 'selenium-standalone install' ]
2020-04-17T21:39:25.3751608Z 12 silly lifecycle temp@1.0.0~e2e-setup: Returned: code: 255  signal: null
2020-04-17T21:39:25.3752743Z 13 info lifecycle temp@1.0.0~e2e-setup: Failed to exec e2e-setup script
2020-04-17T21:39:25.3753814Z 14 verbose stack Error: temp@1.0.0 e2e-setup: `selenium-standalone install`
2020-04-17T21:39:25.3754348Z 14 verbose stack Exit status 255
2020-04-17T21:39:25.3755003Z 14 verbose stack     at EventEmitter.<anonymous> (/vsts/agent/_work/_tool/node/6.17.1/x64/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
2020-04-17T21:39:25.3755744Z 14 verbose stack     at emitTwo (events.js:106:13)
2020-04-17T21:39:25.3756353Z 14 verbose stack     at EventEmitter.emit (events.js:191:7)
2020-04-17T21:39:25.3757140Z 14 verbose stack     at ChildProcess.<anonymous> (/vsts/agent/_work/_tool/node/6.17.1/x64/lib/node_modules/npm/lib/utils/spawn.js:40:14)
2020-04-17T21:39:25.3757834Z 14 verbose stack     at emitTwo (events.js:106:13)
2020-04-17T21:39:25.3758420Z 14 verbose stack     at ChildProcess.emit (events.js:191:7)
2020-04-17T21:39:25.3759038Z 14 verbose stack     at maybeClose (internal/child_process.js:920:16)
2020-04-17T21:39:25.3759714Z 14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
2020-04-17T21:39:25.3760203Z 15 verbose pkgid temp@1.0.0
2020-04-17T21:39:25.3760616Z 16 verbose cwd /vsts/agent/_work/r2/a/_QA_IDLookUp
2020-04-17T21:39:25.3761457Z 17 error Linux 5.0.0-1031-azure
2020-04-17T21:39:25.3762546Z 18 error argv "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/node" "/vsts/agent/_work/_tool/node/6.17.1/x64/bin/npm" "run" "e2e-setup"
2020-04-17T21:39:25.3763170Z 19 error node v6.17.1
2020-04-17T21:39:25.3763496Z 20 error npm  v3.10.10
2020-04-17T21:39:25.3763826Z 21 error code ELIFECYCLE
2020-04-17T21:39:25.3764642Z 22 error temp@1.0.0 e2e-setup: `selenium-standalone install`
2020-04-17T21:39:25.3765087Z 22 error Exit status 255
2020-04-17T21:39:25.3765921Z 23 error Failed at the temp@1.0.0 e2e-setup script 'selenium-standalone install'.
2020-04-17T21:39:25.3766518Z 23 error Make sure you have the latest version of node.js and npm installed.
2020-04-17T21:39:25.3767106Z 23 error If you do, this is most likely a problem with the temp package,
2020-04-17T21:39:25.3767909Z 23 error not with npm itself.
2020-04-17T21:39:25.3768396Z 23 error Tell the author that this fails on your system:
2020-04-17T21:39:25.3769248Z 23 error     selenium-standalone install
2020-04-17T21:39:25.3769864Z 23 error You can get information on how to open an issue for this project with:
2020-04-17T21:39:25.3770358Z 23 error     npm bugs temp
2020-04-17T21:39:25.3771224Z 23 error Or if that isn't available, you can get their info via:
2020-04-17T21:39:25.3771966Z 23 error     npm owner ls temp
2020-04-17T21:39:25.3772352Z 23 error There is likely additional logging output above.
2020-04-17T21:39:25.3772813Z 24 verbose exit [ 1, true ]
2020-04-17T21:39:25.3773034Z 
2020-04-17T21:39:25.3775507Z ##[error]Error: Npm failed with return code: 1
2020-04-17T21:39:25.3816759Z ##[section]Finishing: npm run e2e-setup

node和npm的版本好像很老了。我在 travis、azure devops 和 github 操作上使用 selenium 进行了 运行 守夜人测试。我的建议是通过一个非常简单的 yml 文件进行配置。你可以在下面看到我的link并尝试一下。

参考:https://github.com/spnraju/nightwatchjs-selenium-example/blob/master/azure-pipelines.yml