browserstack/browserstack-runner

Loading js-reporters.js fails after installing with npm3

Closed this issue · 2 comments

See here: https://github.com/browserstack/browserstack-runner/blob/master/lib/server.js#L48

It attempts to load path.join(__dirname, '../node_modules/js-reporters/dist/js-reporters.js'), which would be valid if browserstack-runner was installed as a dependency by npm2.

However, npm3 installs dependencies as flat as possible, meaning that the js-reporters dependency could be anywhere up the directory structure.

When running tests, this issue manifests itself via this stack trace:

Launching 1 worker(s) for 1 run(s).
fs.js:634
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/josh/code/abstract-state-router/node_modules/browserstack-runner/node_modules/js-reporters/dist/js-reporters.js'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at getReporterPatch (/Users/josh/code/abstract-state-router/node_modules/browserstack-runner/lib/server.js:49:34)
    at writeResponse (/Users/josh/code/abstract-state-router/node_modules/browserstack-runner/lib/server.js:90:19)
    at /Users/josh/code/abstract-state-router/node_modules/browserstack-runner/lib/server.js:129:13
    at tryToString (fs.js:449:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)

Could you update your patch using resolve on top of current master and send a PR?

Sorry for the long wait! I opened pull request #170 based on the current master branch.