Home > database >  Is it necessary to install Electron module and save it as devDependencies in project folder or insta
Is it necessary to install Electron module and save it as devDependencies in project folder or insta

Time:07-23

I'm working with Electron to build an app and I find that we can install Electron module globally by npm install -g electron instead of npm install --save-dev electron as the documentations said. I think this will reduce the app size. But I'm afraid of there will be an error when packaging the source code or while the user use the app. Can we install Electron module globally without any error and if can, will the app size reduce when we package it?

CodePudding user response:

No, you need to install it locally in the package, because as you say, packaging the app will fail.

Actually, you won't even be able to build your app.

Something like what you're describing has been suggested on their Github page. See here, but I doubt they'll implement this any time soon.

CodePudding user response:

Installing Electron locally (within your project) or globally will make no difference to the size of the built application.

It is common practice to install Electron locally within your project as a dev-dependency. Doing so will prevent the need to constantly change its version number when working on different Electron applications should their Electron version numbers differ.

When your application is built, all the necessary binaries, etc are packaged up within your application. IE: Your built Electron application is self-contained.

  • Related