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

Issue using dugite with electron and webpack #196

Closed
joecorkerton opened this issue Jun 11, 2018 · 9 comments
Closed

Issue using dugite with electron and webpack #196

joecorkerton opened this issue Jun 11, 2018 · 9 comments

Comments

@joecorkerton
Copy link

joecorkerton commented Jun 11, 2018

I am trying to test out dugite with a fresh electron project and I'm having problems getting it running. I'm using webpack to bundle the js, which is producing the following errors:

Module not found: Error: Can't resolve 'child_process' in '../node_modules/dugite/build/lib'
Module not found: Error: Can't resolve 'fs' in '../node_modules/dugite/build/lib'

I tried setting the LOCAL_GIT_DIRECTORY environment variable but that did not resolve the issue.

Any suggestions to get it working?

@kittaakos
Copy link
Contributor

If you have this issue when creating the bundle.js, you could try to work around it by mocking node in your webpack.config.js:

module.exports = {
  // ...
  node: {
    fs: 'empty',
    child_process: 'empty'
    // ...
  }
  // ...
};

@shiftkey
Copy link
Member

@joecorkerton are you able to share an example webpack config for how you're doing the bundling? We do this with Desktop, but it'd be nice to have an agnostic demo project to help with troubleshooting, as this seems different to what we uncovered with bundling in #96.

@joecorkerton
Copy link
Author

@shiftkey I've created a new repo with the minimum setup required to produce the error. It can be found here https://github.com/joecorkerton/dugite-test

@joecorkerton
Copy link
Author

@kittaakos I can do that and I no longer get an error while bundling, but then dugite no longer works:

Error: Git not supported on platform: undefined

@kittaakos
Copy link
Contributor

I got the very same result. I am positive, it is possible to use dugite in electron. I give it another try ...

@kittaakos
Copy link
Contributor

I have created a PR against your setup: https://github.com/joecorkerton/dugite-test/pull/1
I am able to call dugite, but it results in an error:

Uncaught (in promise) Error: Git could not be found at the expected path: '/git/bin/git'. This might be a problem with how the application is packaged, so confirm this folder hasn't been removed when packaging.
    at bundle.js:1
    at exithandler (child_process.js:294)
    at ChildProcess.errorhandler (child_process.js:306)
    at emitOne (events.js:116)
    at ChildProcess.emit (events.js:211)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:196)
    at onErrorNT (internal/child_process.js:372)
    at _combinedTickCallback (internal/process/next_tick.js:138)
    at process._tickCallback (internal/process/next_tick.js:180)

I could take another look tomorrow. There must be something with the bundling process.

By the way, you can also check out this dugite-electron boilerplate: https://github.com/kittaakos/electron-boilerplate

@kittaakos
Copy link
Contributor

If I hack the git path (in debug mode), then it works.

screen shot 2018-06-13 at 17 47 28

@joecorkerton
Copy link
Author

joecorkerton commented Jun 15, 2018

@kittaakos I have gotten a bit further now. If I set the target in the webpack.config to electron-renderer then the issue about not finding fs and child_process is gone (it no longer needs to be stubbed in the config as you suggested).

However now I also get the same issue with the git path (git/bin/git). Will look into this further as it seems to be related to #96.

I pushed up a new commit which has most of the changes in your PR

@joecorkerton
Copy link
Author

joecorkerton commented Jun 15, 2018

I still don't fully understand the issue, but when I create a new electron app with https://github.com/electron-userland/electron-webpack-quick-start it seems to work, so I will go with that for now.

Thanks for your help

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