Electron-builder: Error: electron must be in the devDependencies

Created on 15 Nov 2016  ยท  9Comments  ยท  Source: electron-userland/electron-builder

  • Version:

Latest -> 8.6.0

  • Target:

Whatever

It happens as soon as I try to use the script node_modules/.bin/build. I can't get rid of the following error:

screen shot 2016-11-15 at 13 39 22

I used to make it work but something is definitively broken now. Here is the current packages I use for now:

image

Thanks in advance for your help.

question

All 9 comments

electron must be in the devDependencies. It is valid error.

something is definitively broken now

Runtime error?

I understand what's going on. I have the following project architecture:

.
โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ ...
โ”‚ย ย  โ””โ”€โ”€ package.json (B)
โ”œโ”€โ”€ ...
โ””โ”€โ”€ package.json (A)

The file (A) contains all the electron stuff (and electron in devDependendies) to build my app and the file (B) contains what's needed by my app. In my app, I do import the ipcRenderer from electron and so I put electron inside of ... dependencies in the file (B).

Removing electron from the dependencies of the file (B) fixed the problem. The thing I don't understand is why the checkDependencies of the packager.ts produces an error for this case. Since I'm calling it from my root folder, it should not care about the app/ folder right?

Btw, thank you for your quick answer. Effectively electron-builder was providing a correct error given the context explained on my previous answer.

I'm calling it from my root folder, it should not care about the app/ folder right?

No, you use two-package.json structure and electron-builder aware about it. BTW, since electron-builder 8 consider to use simple 1 package.json structure (https://github.com/electron-userland/electron-builder/issues/906).

I do import the ipcRenderer from electron and so I put electron inside of ... dependencies in the file (B).

Doesn't matter. electron is not resolved as standard node module. It is not node module. So, electron dependency is required only and only if you want to run your app without pack.

Thanks for you help @develar

Just wanna say that while the error message is technically correct, it is still confusing to (especially new) users of electron / electron-builder. Ideally the message would explicitly state that the electron dependency has been found inside of dependencies, instead of inside the devDependencies section. That would make the solution that much easier to find.
Aside from that, thanks for making this software! Using it for the first time, enjoying it!

@seeekr Thanks for note. PR to correct warning text is welcome ;)

@develar #986 :)

Was this page helpful?
0 / 5 - 0 ratings