0

我正在尝试使用 Zombie 驱动程序创建 Mink 连接,但出现错误。所有端口都是打开的,我尝试使用我的服务器 IP。

我的代码:

$driver = new \Behat\Mink\Driver\ZombieDriver('127.0.0.1');
$zombieSession = new \Behat\Mink\Session($driver);
$zombieSession->start();

错误:

Fatal error: Uncaught exception 'RuntimeException' with message 'Server process has 
been terminated: (127) [sh: node: command not found ]' in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php:406
Stack trace: #0 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php(302): 
Behat\Mink\Driver\NodeJS\Server->checkAvailability() #1 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php(107): 
Behat\Mink\Driver\NodeJS\Server->start() #2 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink/src/Behat/Mink/Session.php(62): 
Behat\Mink\Driver\ZombieDriver->start() #3 /home/runniog5/public_html/subdomains/testing4/test.php(114): 
Behat\Mink\Session->start() #4 {main} thrown in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php 
on line 406
4

2 回答 2

0

确保您已安装 Node 并且它可以正常工作。Server process has been terminated: (127) [sh: node: command not found ]告诉你 shell 找不到 node 命令。为了验证你已经运行node -v它,它应该打印当前安装的版本。

于 2014-07-12T08:45:52.767 回答
0

问题是 ZombieServer 不知道节点二进制文件的路径。要解决此问题,请使用以下代码:

$zombieServer = new ZombieServer($host, $port, $pathToYourNodeBinary, $serverPath, $threshold, $pathToYourNodeModules);
$zombieDriver = new ZombieDriver($zombieServer);
$session = new Session($zombieDriver);
$mink = new Mink(array('zombie' => $session));

就我而言, $pathToYourNodeBinary 和 $pathToYourNodeModules 是:

$pathToYourNodeBinary = '/usr/local/bin/node';
$pathToYourNodeModules = '/usr/local/lib/node_modules/';

您可以使用这些命令了解您的路径(如果您使用 OSX 运行 Mac):

which node
which npm

当然,您需要设置其余的 ZombieServer 构造函数变量。要了解默认值,只需查看您的供应商库或github.com中的实现

于 2015-06-22T16:08:50.730 回答