简体   繁体   English

在 Linux 上运行 node.js 时如何解决“服务器提前终止,状态为 127”的问题?

[英]How do I solve “Server terminated early with status 127” when running node.js on Linux?

I'm using node 5.10.0 on this version of Linux我在这个版本的 Linux 上使用节点 5.10.0

[davea@mydevbox mydir]$ uname -a
Linux mydevbox.mydomain.com 7.3.8-25.26.amzn1.x86_64 #1 SMP Wed Mar 16 17:15:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

I'm getting the below error when running my script (“Server terminated early with status 127”).运行脚本时出现以下错误(“服务器提前终止,状态为 127”)。 I have verified that I can reach the URL in question using “wget”, so I can't tell what else I need to make this thing work …我已经验证我可以使用“wget”访问有问题的 URL,所以我不知道我还需要什么才能使这个东西工作......

[davea@mydevbox mydir]$ node myscript.js 
Validation Complete
/home/davea/node_modules/selenium-webdriver/lib/promise.js:654
    throw error;
    ^

Error: Server terminated early with status 127
    at Error (native)
    at /home/davea/node_modules/selenium-webdriver/remote/index.js:242:20
    at ManagedPromise.invokeCallback_ (/home/davea/node_modules/selenium-webdriver/lib/promise.js:1343:14)
    at TaskQueue.execute_ (/home/davea/node_modules/selenium-webdriver/lib/promise.js:2868:14)
    at TaskQueue.executeNext_ (/home/davea/node_modules/selenium-webdriver/lib/promise.js:2851:21)
    at /home/davea/node_modules/selenium-webdriver/lib/promise.js:2730:27
    at /home/davea/node_modules/selenium-webdriver/lib/promise.js:639:7
    at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
    at acquireSession (/home/davea/node_modules/selenium-webdriver/lib/webdriver.js:107:22)
    at Function.createSession (/home/davea/node_modules/selenium-webdriver/lib/webdriver.js:337:12)
    at Driver (/home/davea/node_modules/selenium-webdriver/chrome.js:778:38)
    at Builder.build (/home/davea/node_modules/selenium-webdriver/builder.js:464:16)
    at Object.<anonymous> (/home/davea/mydir/js/Optimus.js:14:4)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
From: Task: WebDriver.navigate().to(http://localhost:8081/myproject)
    at Driver.schedule (/home/davea/node_modules/selenium-webdriver/lib/webdriver.js:386:17)
    at Navigation.to (/home/davea/node_modules/selenium-webdriver/lib/webdriver.js:1029:25)
    at Driver.get (/home/davea/node_modules/selenium-webdriver/lib/webdriver.js:797:28)
    at Object.exports.Login.Page (/home/davea/mydir/js/Optimus.js:505:16)
    at Object.exports.smokeTest (/home/davea/mydir/js/Optimus.js:2442:19)
    at Object.<anonymous> (/home/davea/mydir/SkyNet.js:13:6)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

In my case I was missing a Java Runtime environment (JRE).就我而言,我缺少 Java 运行时环境 (JRE)。 I'm running e2e tests with Selenium in a Debian-based docker image, hence apt-get install default-jre did the trick for me.我正在基于 Debian 的 docker 映像中使用 Selenium 运行 e2e 测试,因此apt-get install default-jre对我apt-get install default-jre It's a pity selenium doesn't give a more useful error message in this case.遗憾的是,在这种情况下,硒没有给出更有用的错误消息。

As suggested by other answers, the error message means you have unmet dependencies.正如其他答案所建议的那样,错误消息意味着您有未满足的依赖项。

In my case of selenium e2e test, fixes are:在我的硒 e2e 测试的情况下,修复是:

  1. apt-get install default-jre as mentioned by @Johannes @Johannes 提到的apt-get install default-jre
  2. apt-get -f install for a fix install apt-get -f install用于修复安装
  3. apt-get install chromium-browser Make sure to install the correct version of chrome related to your chromedriver, eg chrome 60-62 for chromedriver 2.33 apt-get install chromium-browser installchromium apt-get install chromium-browser确保安装与您的 chromedriver 相关的正确版本的 chrome,例如 chromedriver 2.33 的 chrome 60-62
  4. Config webdriver to start chrome in 'headless' mode, as to avoid other unnecessary dependencies.配置 webdriver 以“无头”模式启动 chrome,以避免其他不必要的依赖。 In node it looks like:在节点中它看起来像:

const options = new chromeDriver.Options(); options.addArguments( 'headless', 'disable-gpu', ); new webdriver.Builder() .forBrowser('chrome') .setChromeOptions(options) .build();

I had a similar issue where it was missing a shared library that I solved by symlinking libnss3.so:我有一个类似的问题,它缺少一个我通过符号链接 libnss3.so 解决的共享库:

ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/libnss3.so

If the first directory doesn't work for you, find with:如果第一个目录不适合您,请查找:

find /usr/lib/ -name libnss3* OR find /usr/lib64/ -name libnss3* find /usr/lib/ -name libnss3*find /usr/lib64/ -name libnss3*

and replace accordingly.并相应地更换。

It might also require an update, so try: yum update nss它可能还需要更新,所以请尝试: yum update nss

I was using node.js based selenium script and overcome the issue by installing google chrome manually using the command curl https://intoli.com/install-google-chrome.sh | bash我使用的是基于 node.js 的 selenium 脚本,并通过使用curl https://intoli.com/install-google-chrome.sh | bash命令手动安装谷歌浏览器来解决这个问题curl https://intoli.com/install-google-chrome.sh | bash curl https://intoli.com/install-google-chrome.sh | bash

This worked for me.这对我有用。 Please give a try.请试一试。 Thanks.谢谢。

I had the same problem.我有同样的问题。 I had different versions of chromedriver and google-chrome-stable package in Ubuntu.我在 Ubuntu 中有不同版本的 chromedriver 和 google-chrome-stable 包。 I checked the chrome version by google-chrome-stable --version CLI command.我通过google-chrome-stable --version CLI 命令检查了 chrome 版本。 And then downloaded the suitable chromedriver from here: http://chromedriver.storage.googleapis.com/index.html .然后从这里下载合适的 chromedriver: http ://chromedriver.storage.googleapis.com/index.html。 Copped it into /usr/bin/local and set 777 permissions to the file.将其复制到 /usr/bin/local 并为该文件设置 777 权限。 Everything started working.一切都开始工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM