Electron-builder: install-app-dependencies

Created on 14 Nov 2016  Â·  9Comments  Â·  Source: electron-userland/electron-builder

quick question to understand correctly.

install-app-dependencies is a replacement for electron-rebuild, right?

question

All 9 comments

install-app-dependencies is a replacement for electron-rebuild, right?

Not quite. Please see readme — "To ensure your native dependencies are always matched electron version".

But! As electron-builder is a complete solution — you don't need to explicitly use it. Because in any case your native deps will be rebuild during build.

The only install-app-dependencies use case — when you run npm install && npm run myCoolApp i.e. you want to install all deps and run app using electron-prebuilt (electron). In this case no actual build, and, so, explicit install-app-dependencies is required.

@develar thanks but i am not sure i quite get it.
Until now i had

"scripts": {
    "postinstall": "node ../tasks/rebuild_native_modules" //use electron-rebuild
  }

in my app package.json and

 "scripts": {
    "postinstall": "cd app && npm install --production && cd .. && install-app-deps",
  }

in my main package.json (with dev dependencies).
It was working quite well but rebuild_native_modules was too long.

Thus my question. So i tried removing rebuild_native_modules, then run npm install in my project root, then run the app

I ended up having an error about a bindings not beeing built for my electron version.
I put back rebuild_native_modules, then npm install, then start, and it now works.

So should i understand that i still need to use electron-rebuild?

As you said i was starting to see electron-builder as a complete solution, so i was wondering if it would not only build native deps for "packaging" but also for dev run.

You don't need to use two-package.json project structure anymore (since 8). Sample app https://github.com/develar/onshape-desktop-shell is switched to one-package.json structure.

So should i understand that i still need to use electron-rebuild?

You don't need to use electron-rebuild.

I ended up having an error about a bindings not beeing built for my electron version.

  • "postinstall": "install-app-deps" must be in the dev (root) package.json . Your usage is correct.
  • You should not call cd app && npm install --production — it is error, please remove it. install-app-deps is enough.

I recommend you to use one-package.json structure (using electron-builder >= 8.5.3). In this case you just use script "postinstall": "install-app-deps" and no more puzzle "dev vs app package.json".

@develar thanks for the clarification. Actually i prefer the 2-package.json structure because it makes sure i don't put dev packages inside my app installer/dmg.
With only one how do you make sure dev packages are not packaged? (this might be another discussion)

Anyway will try without electron-rebuild`` and report here. BTW i will keepcd app && npm install --production``` because i want to make sure my app/ node_modules are up to date and compiled.

EDIT: i now looking at the code that install-app-deps actually runs npm install in my app dir.
So i will remove it as you mentioned ;-)

because it makes sure i don't put dev packages inside my app installer/dmg

electron-builder is smart enough to not pack dev packages. Only production deps are packed.

i will keepcd app && npm install --production``` because i want to make sure my app/ node_modules are up to date and compiled.

You don't need and should not. If you use 2-package.json structure we always do full install.

@develar can you point to where you check for production/dev packages for packaging?
Would like to see how it is done to make sure that's what i would want.

Thanks

point to where you check for production/dev packages for packaging

https://github.com/electron-userland/electron-builder/blob/master/src/platformPackager.ts#L194

@develar thanks i now understand how you do it. Will try with only one package.json

Was this page helpful?
0 / 5 - 0 ratings