我正在尝试使用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
答案 0 :(得分:0)
确保已安装Node且功能正常。 Server process has
been terminated: (127) [sh: node: command not found ]
告诉您shell无法找到node命令。要验证您是否运行node -v
,它应该打印当前安装的版本。
答案 1 :(得分: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
中的实施情况