Ad

Does Phantomjs Have Something Similar To Node_modules?

- 1 answer

Does phantomjs have something similar to node_modules (from nodejs) ?

This is so I can use something like require('moduleName'); to make the code cleaner.

Ad

Answer

You can use injectJs to dynamically load phantom scripts.

  console.log(phantom.injectJs('./path-to-file.js'));

From the wiki

injectJs(filename) {boolean}

Injects external script code from the specified file into the Phantom outer space. If the file cannot be found in the current directory, libraryPath is used for additional look up. This function returns true if injection is successful, otherwise it returns false.

https://github.com/ariya/phantomjs/wiki/API-Reference

Ad
source: stackoverflow.com
Ad