Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron path in 1.3.5 doesn't exist #180

Open
regentcid434 opened this issue Apr 13, 2022 · 6 comments
Open

Electron path in 1.3.5 doesn't exist #180

regentcid434 opened this issue Apr 13, 2022 · 6 comments

Comments

@regentcid434
Copy link

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
Copy link
Collaborator

jjeff commented Apr 13, 2022

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.

@OsamaAbbas
Copy link
Collaborator

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.

@regentcid434
Copy link
Author

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.

@OsamaAbbas
Copy link
Collaborator

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.

@regentcid434
Copy link
Author

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.

@OsamaAbbas
Copy link
Collaborator

No worries, take your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants