Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slimerjs Can not resolve required module, works with phantomjs

I am trying to create a testing script so that the testers can capture some tests using standalone slimerjs 0.9.3. However when I try to require a local package that I installed(minimist in this case) via npm I get an error.

File structure:

clibrowsers/
    /osx/slimer/slimerjs
    /scripts
        /batchprinter.js
        /node_modules/minimist/
    ...

When I run "clibrowsers/osx/slimer/slimerjs clibrowsers/scripts/batchprinter.js" I get the error:

Script Error: Module: Can not resolve "minimist" module required by main located at file:///Users/USER/Documents/dev/clibrowsers/scripts/batchprinter.js
       Stack:
         -> file:///Users/USER/Documents/dev/clibrowsers/scripts/batchprinter.js: 351

When run the script with with phantomjs 2.0.0 (development) I do not get any errors.

What am I doing wrong?

like image 261
chris Avatar asked Nov 01 '22 15:11

chris


1 Answers

slimer cannot find the node_modules on its own, but you can load the module manually, for instance: var uuid = require(fs.workingDirectory+'/node_modules/node-uuid/uuid.js');

see the doc on slimerjs require

like image 120
Mortimer Avatar answered Nov 15 '22 04:11

Mortimer