bytenode/bytenode

Electron path in 1.3.5 doesn't exist

regentcid434 opened this issue ยท 6 comments

With the latest update, I am getting this error. Electron is clearly installed, but bytenode is unable to find it. Line 49 in lib/index.js was changed recently which seemed to break it. Console logging electronPath returns just 'cli.js'. Downgrading to 1.3.4 fixes the issue.

image

jjeff commented

I've tested 1.3.5 in both via the Mocha tests in the bytenode repo and via electron-bytenode-example. I can't replicate this error. Maybe @OsamaAbbas will have an idea. But is there a simplified version of the problem that you post somewhere?

It sounds like require.resolve('electron') is returning an empty string for some reason.

I guess the problem is because your electron is locally installed and you are trying to use the globally-installed bytenode.

With the latest change, (global) bytenode will look for the globally-installed electron, not the local one.

This is not the desired behavior in my opinion. Bytenode should always use the locally-installed electron first. I'm not sure if it should look for the global one at all. (This depends on how electron apps building tools work though).

So, as a proposed fix, we can tell the require.resolve function where to look:

const modulePaths = [process.cwd(), ...require.resolve.paths('electron')];
const electronPath = path.join(path.dirname(require.resolve('electron', { paths: modulePaths })), 'cli.js');

Another workaround is to use the locally-installed bytenode: $ ./node_modules/.bin/bytenode -c -e index.js.

I have neither bytenode nor electron installed globally. Both are local to the project. It does seem to be returning an empty string, but I'm not sure why.

If both are installed locally, then I cannot reproduce your issue. If you can create a minimal setup that shows the error, then we can look into it.

I'm currently halfway through a sprint, and rolling back to the previous version works for now. Once I have a minute, I'll try setting this up in a new project to see if I can replicate it. Thanks for the quick replies.

No worries, take your time.