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

Some node modules not working in application packaged with electron-builder #602

Closed
Mercieral opened this issue Jul 19, 2016 · 10 comments · May be fixed by qcif/data-curator#563
Closed

Some node modules not working in application packaged with electron-builder #602

Mercieral opened this issue Jul 19, 2016 · 10 comments · May be fixed by qcif/data-curator#563
Labels

Comments

@Mercieral
Copy link

Mercieral commented Jul 19, 2016

Hello,

So my building order goes as such (I've gone over this before but it's important). First I grunt build my application into an "electron_build" which also copies over the necessary node_modules and the application's package.json. Then I use electron builder with directories.app set to "electron_build" and directories.buildResources set to "electron/resources" (the only things in this directory are the 2 icons).

My app is using node_notifier to show native desktop notifications.

The notifications work perfectly with electron-prebuilt using "electron ."
The notifications also work perfectly with the .app generated from electron-packager
But the notifications do not work in the .app or the installed app from electron-builder.

I am not sure what is causing this but it seems like electron-builder is reinstalling node-notifier which is not necessary as I already have it included in the app directory and my grunt task makes some important modifications to the node_module.

Any suggestions or thoughts as to why it is working with electron-packager but not electron-builder?

@develar
Copy link
Member

develar commented Jul 19, 2016

If you copy node_notifier to app node_modules, so, electron-builder must not rebuild it again.

Please set build.npmRebuild to false In this case it is your responsibility to build native dependencies correctly.

@Mercieral
Copy link
Author

Well that stopped it from rebuilding node_modules but the notifications still do not appear to be working. I will dig deeper and see what I can find.

I was actually looking/hoping for an option that stops the npm rebuild but that option is missing from the "options" documentation so I was not aware of it.

@develar
Copy link
Member

develar commented Jul 19, 2016

@Mercieral Please note that asar is enabled by default in the electron-builder and not enabled in the electron-packager. Set build.asar to false — does it help?

@Mercieral
Copy link
Author

Mercieral commented Jul 19, 2016

@develar That did it. I suppose I should have looked at electron's packaging docs a little closer as it details that some node-api's do not work using electron's asar archive, which I was unaware of.

Thanks for your help and extremely quick responses!

@develar
Copy link
Member

develar commented Jul 19, 2016

For several months I wait user who send me (develar@gmail.com) real project to demonstrate issue — the truth is that electron-builder can and should automatically solves such issues. To avoid explicit asar.unpackDir usage or disabling asar (windows io sucks and you should not disable asar).

If you send me project and it will be possible to reproduce the issue, I will fix it.

@Mercieral
Copy link
Author

I unfortunately cannot send you the project I am on currently as I am not in control of it and it is a private project. I will however try to create a small public project on my own sometime today that will recreate the issue I am having and send it to you.

From what I remember from using the electron-winstaller is that if asar is disabled, then I would get filePathTooLong errors on install or something similar so I would definitely prefer having it enabled if notifications will work.

@Mercieral
Copy link
Author

Mercieral commented Jul 19, 2016

https://github.com/Mercieral/Electron-with-notifications Here is a link to a very simple project that recreates it. Thanks

unpackDir seems to be working perfectly. Is this bad practice to use this option?

https://www.npmjs.com/package/node-notifier#within-electron-packaging Node-notifier is aware of this issue

@develar
Copy link
Member

develar commented Jul 20, 2016

Thanks, I cannot promise that I will fix/investigate it today, but this week.

On Jul 19, 2016, at 8:21 PM, Aaron Mercier notifications@github.com wrote:

https://github.com/Mercieral/Electron-with-notifications
Here is a link to a very simple project that recreates it. Thanks


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
, or mute the thread
.

@Mercieral
Copy link
Author

Mercieral commented Jul 20, 2016

Sounds good,

On a related note, I am trying to get the squirrel.Windows installer to work but since I am using npm 2, the node_modules folder is too long and it fails the install with a PathTooLongException.

So I switched to the newest version of npm (3.10.5) and reinstalled all my dependencies, removed the grunt task that manually copies over the node_modules (because this does is not easy with npm 3's flat structure), and set the npmRebuild to true again but the build just says "Rebuilding app dependencies for arch x64 to /Users/amercier/...../electron_build" and nothing after that and goes straight into the packaging step. My app's package.json that is located in electron_build is as follows,

{
  "name": "myApp",
  "version": "0.1.0",
  "main": "main.js",
  "author": "Aaron Mercier",
  "homepage": "https://github.com/Mercieral",
  "description": "A sample electron application",
  "license": "",
  "scripts": {
    "start": "node ./start-electron.js"
  },
  "dependencies": {
    "electron-json-storage": "2.0.0",
    "electron-squirrel-startup": "1.0.0",
    "node-notifier": "4.6.0",
    "query-string": "4.2.2"
  }
}

I'm also getting

Warning: homepage in the development package.json is deprecated, please move to the application package.json
Warning: license in the development package.json is deprecated, please move to the application package.json

in which there is no homepage field in my development package.json...

Is it possible this is an issue with setting directories.app to something other than the default? As I set mine to my "electron_build" directory.

EDIT: It does something if I have all of the node_modules installed in my electron_build directory, so I believe I am misunderstanding what the npmRebuild does exactly.

@develar
Copy link
Member

develar commented Jul 28, 2016

Is it possible this is an issue with setting directories.app to something other than the default? As I set mine to my "electron_build" directory.

No, Warning: homepage is not related, but fixed. Thanks a lot for sample project.

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

Successfully merging a pull request may close this issue.

2 participants