3

Ok I see this question has been asked before however when I looked at the answers I am still unable to correctly set the environment variable. I tried using the export command but export is not recognized as an internal or external command. Does anyone know how to correctly set the env variable for PHANTOMJS_BIN without using the export command? The errors I am getting are cannot start PhantomJS can not find the binary C:\users.. please set env variable PHANTOMJS_BIN error in plugin gulp-karma karma exited with code

My node version is 4.4.2

Flash
  • 924
  • 3
  • 22
  • 44

1 Answers1

1

It seems that you're using Windows. You can set an environment variable as shown in this question. Don't forget to reopen terminal after that.

For export command to work you'd need to use some unix terminal emulator, for example Git bash which is included with Git for Windows (Git/bin/bash.exe).

But the real reason why env var won't work, I suspect, is a misconfiguration of PhantomJS path in Karma's config file, as described in this issue. It seems that at the very beginning of karma.conf.js there is an incorrect setting overriding PATH variable:

process.env.PHANTOMJS_BIN = 'node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs';

If you remove it then the settings from PATH will be used. Or you could hardcode the real location of PhantomJS binary in order not to pollute PATH.

Community
  • 1
  • 1
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • Definitely check karma.conf.js for incorrect hardcoded `process.env.PHANTOMJS_BIN` variable. – Vaviloff Nov 22 '16 at 04:44
  • in that file it looks like no base path set. it must be using the settings as you stated – Flash Nov 22 '16 at 14:21
  • I was able ot fix the problem by copying the phantomjs.exe into the path it was looking for. However this is not the correct way since it will only work locally. what npm command would I use to fix it globally Thanks – Flash Nov 30 '16 at 14:09
  • How does it know where to look for? – Vaviloff Nov 30 '16 at 15:12
  • I'm not even sure – Flash Nov 30 '16 at 16:32
  • I'm not sure why that is even a case. What have you used to scaffold the project? Could be an incorrect / outdated template, as is supposed in this [issue](https://github.com/karma-runner/karma-phantomjs-launcher/issues/69) – Vaviloff Dec 01 '16 at 04:49