slimerjs Can not resolve required module, works with phantomjs

江枫思渺然 提交于 2020-02-19 05:56:28

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/26496004/slimerjs-can-not-resolve-required-module-works-with-phantomjs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!