1

i'm trying to require() and use this logging module (it has some dependencies also) in phatomJS but it fails and prints this error:

C:\node\scrap>phantomjs app.js
ReferenceError: Can't find variable: process

  phantomjs://platform/index.js:3
ReferenceError: Can't find variable: process

  phantomjs://platform/index.js:9
TypeError: undefined is not an object (evaluating 'chalk.bold.red')

  phantomjs://platform/index.js:29
TypeError: undefined is not a constructor (evaluating 'log.info('All settings loaded, start with exe
cution')')

  phantomjs://code/app.js:16 in global code

I don't know why or what's wrong ? what am I missing ?

Xsmael
  • 3,624
  • 7
  • 44
  • 60
  • Possible duplicate of [Use a node module from casperjs](http://stackoverflow.com/questions/24387854/use-a-node-module-from-casperjs) – Artjom B. Jun 02 '16 at 14:34
  • There is no `process` module in PhantomJS, – Artjom B. Jun 02 '16 at 14:34
  • 1
    Keep in mind, PhantomJS is a headless browser — which makes it great for testing things that are reliant on a browser, such as accessing document and window objects. If you want to use modules within Phantom JS, I would imagine that you would need to jump through many of the same hoops one would need to jump through to get the same code to run in non-headless browsers. – Pytth Jun 02 '16 at 14:51
  • Hum, so basically it's not possible, is there any workaround solution for this ? – Xsmael Jun 02 '16 at 15:03
  • I ran in to this as well. A couple of things to try - this issue is with the module you require. Look at the modules it depends on - those are causing you a problem. – DFBerry Aug 12 '16 at 19:59

0 Answers0