electron-userland / electron-prebuilt-compile

electron-prebuilt with Babel and React built-in
168 stars 56 forks source link

Bug (?) in findPackageJson in es6-init.js #39

Closed wolfgang closed 7 years ago

wolfgang commented 7 years ago

Hello,

the code in es6-init.js fails to find the correct package.json when it is called from another node-module that has been installed via nvm. In this case, findPackageJson will walk up all the way to the .nvm directory, and subsequently electron-compile will find a .cache directory there, which is not meant for it. Then it crashes.

Scenario: I have a project using electron-prebuilt-compile I call electron with electron-mocha, like this: ELECTRON_PATH=./node_modules/.bin/electron electron-mocha ./test

This fails with: App threw an error during load Error: ENOENT: no such file or directory, open '/Users/wodev/.nvm/.cache/compiler-info.json.gz'

Analysis: electron-mocha ends up calling electron with a path like below: $HOME/.nvm/versions/node/v8.1.2/lib/node_modules/electron-mocha/index.js

Since findPackageJson skips over everything under a node_modules folder, it ends up in the nvm home directory.