minkphp / MinkZombieDriver

Zombie.js driver for Mink framework
41 stars 49 forks source link

Can't find module #192

Closed sidorov89 closed 5 years ago

sidorov89 commented 5 years ago

I'm using zombie driver in yii2. I run my code in console and get error:

'Server process has been terminated: (throw err;
Error: Cannot find module 'lodash'
....
 at Object.<anonymous> (/var/www/mvp/vendor/npm-asset/zombie/lib/tabs.js:15:9

I get error on this row: var = require('lodash'); If I change it to var = require('lodash/lodash.find/index'); I get error in another file Error: Cannot find module 'lodash._basecallback' at /vendor/npm-asset/lodash/lodash.find/index.js:9:20 How can I set in zombie additional folders for searching modules. I load modules in project via composer, not npm, but I have nodeks and npm on my server.

aik099 commented 5 years ago

Have you installed Zombie globally as written in README?

sidorov89 commented 5 years ago

I tried install Zombie globaly via composer, but I couldn't do it. npm-asset/zombie requires npm-asset/jsdom npm-asset/jsdom requires npm-asset/request >=2.88.0,<3.0.0 (there is last v.2.88.1) npm-asset/request v2.88.1 requires npm-asset/tough-cookie ~2.4.3 npm-asset/tough-cookie 2.4.3 requires npm-asset/punycode >=1.4.1,<2.0.0 npm-asset/jsdom 11.5.1 requires npm-asset/whatwg-url npm-asset/whatwg-url 6.3.0 requires npm-asset/tr46 >=1.0.0,<2.0.0 npm-asset/tr46 1.0.0 requires npm-asset/punycode >=2.1.0,<3.0.0

I can't install npm packet via composer because it's impossible

aik099 commented 5 years ago

tried install Zombie globaly via composer, but I couldn't do it.

Not via Composer. But via Node Package Manager like so:

npm install -g zombie

Via Composer you only install Mink & MinkZombieDriver (PHP part), that will internally run Zombie Process via NodeJS and interact with it.

aik099 commented 5 years ago

If that doesn't work, then maybe:

Try installing older version of Zombie and that might work.

aik099 commented 5 years ago

If you manage to install Zombie locally at least with npm install zombie, then you can change Zombie driver initialization code from:

$host       = '127.0.0.1';
$port       = '8124';
$nodeBinary = '/usr/local/bin/node';

$mink = new Mink(array(
    'zombie' => new Session(new ZombieDriver(new ZombieServer(
        $host, $port, $nodeBinary
    ))),
));

into

$host       = '127.0.0.1';
$port       = '8124';
$nodeBinary = '/usr/local/bin/node';
$nodeModulesPath = '...'; // specify path to "node_modules" folder in your project folder, that "npm install" command has created

$zombieServer = new ZombieServer($host, $port, $nodeBinary);
$zombieServer->setNodeModulesPath($nodeModulesPath);

$mink = new Mink(array(
    'zombie' => new Session(new ZombieDriver($zombieServer)),
));

I'm not sure what kind of control you have during instantiation of MinkZombieDriver in YII.

If you're using Behat, then please refer to its docs about Mink driver configuration.

sidorov89 commented 5 years ago

Thanks, I understood. Now it works! )

aik099 commented 5 years ago

Nice. Happy to help. Closing.