As per the official website, the correct way to save electron files is:
npm install electron --save-dev
Electron is actually required for running the app (quite literally: require()
) and this goes against the top voted answer here. So why do we make this exception, if this is even one?
Cause those binary won't being used when you actually packaging into installer. Most of installer / packager for electron will build package with electron binaries, instead of using dependencies.
The fact that you
require
a package is irrelevant to whether it should be considered a dependency or a devDependency (in the npm sense). E.g. many projects use webpack API (i.e.const webpack = require('webpack')
) but list it as a devDependency.The reason is also explained in the post you link to: when you
publish
your package, if the consumer project needs other packages to use yours, then these must be listed asdependencies
.If your package uses some modules only for build, test, or bundles them into a dist file (i.e. what will be used by the consumer project), then those modules should not be mentioned in
dependencies
. We still list them indevDependencies
for development.Now in the case of an electron app, there is little chance you will consume your app as a node module of a consumer project, therefore the above convention is not really relevant.
Furthermore, we fall in the case where the
electron
package is bundled as part of the built output. There is no need for your user to getelectron
from npm to use your built app. Therefore it matches well the definition of a devDependency.That being said, IIRC some electron packagers bundle your
dependencies
into the built app, so you still need some rigour in filling this list.