简体   繁体   English

安装电子与安装电子生成器

[英]install electron vs install electron-builder

What's the difference between installing electron alone vs via electron-builder?单独安装电子与通过电子构建器有什么区别? I'm building an Electron app with React and found a few tutorials already.我正在使用 React 构建一个 Electron 应用程序,并且已经找到了一些教程。 All of them differ how they install Electron, but there is no explanation why.它们安装 Electron 的方式各不相同,但没有解释原因。

First :第一

npx create-react-app app
cd app
npm install electron
npm install --save-dev electron-builder

Second : 第二

create-react-app
npm install --save-dev electron

Third : 第三

create-react-app my-app
cd my-app
yarn add electron --dev
yarn add electron-builder --dev
yarn global add foreman # for process management
yarn install

Two questions:两个问题:

  1. The biggest difference is between First and Second one.最大的区别是第一个和第二个。 In the second tutorial, they didn't even install electron-builder.在第二个教程中,他们甚至没有安装电子生成器。 What's the difference?有什么不同?
  2. The second difference is between First and Third: They both installed electron, but one in dev and another not.第二个区别是 First 和 Third :他们都安装了电子,但一个在开发中,另一个没有。 I'm guessing it should be in --save-dev .我猜它应该在--save-dev Am I correct?我对么?

The electron-builder is a library to build a standalone application for platform os. electron-builder是一个为平台 os 构建独立应用程序的库。 Suppose you want t build a .dmg or .exe for your application, you will need electron-builder .假设您不想为您的应用程序构建.dmg.exe ,您将需要electron-builder It is a packaging and distribution thing we need after completing the application.是我们完成申请后需要的打包分发的东西。 For more information, you can visit www.electron.build .有关更多信息,您可以访问www.electron.build You can use electron-builder with minimal configurations as defined in docs.您可以使用具有文档中定义的最少configurations electron-builder

Answer for Q1 : To packaging the app to installer or executable application whatever you'd like to be. Q1 的答案:将应用程序打包到安装程序或可执行应用程序中,无论您想成为什么。 We can use Electron-Builder or Electron-Package which is popular and well-known Electron packaging tool.我们可以使用Electron-BuilderElectron-Package ,这是一种流行且知名的 Electron 打包工具。 I'd recommend you to have a look at this How to package the electron app我建议你看看这个如何打包电子应用程序

These 3rd party packaging tools are just for your app distribution.这些3rd party packaging tools仅用于您的应用程序分发。 But you can forward manual distribution without using these tools.但是您可以在不使用这些工具的情况下转发 手动分发

The First is the proper way.第一种是正确的方法。 I think the Second one is the case that is not using 3rd party packaging tools.我认为第二种情况是不使用 3rd 方打包工具的情况。

Answer for Q2 : Importing as devDependencies or dependencies won't occur any problem. Q2 的答案:作为 devDependencies 或依赖项导入不会出现任何问题。

But speaking strictly, these should be added as devDependencies .但严格来说,这些应该添加为devDependencies

Both Electron and Electron-Builder is just for needing to build and packaging application. ElectronElectron-Builder都只是为了需要构建和打包应用程序。 And the production app won't require all of these.生产应用程序不需要所有这些。

By your question.根据你的问题。 I'm guessing it should be in --save-dev. Am I correct? Yes, exactly对,就是这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM