Skip to main content

npm 安装 electron

· 6 min read

从 Electron 1.3.1 版本开始,你可以 npm install electron --save-dev 在你的应用中安装最新的预编译版本的 Electron。

¥As of Electron version 1.3.1, you can npm install electron --save-dev to install the latest precompiled version of Electron in your app.


npm install electron

预构建的 Electron 二进制文件

¥The prebuilt Electron binary

如果你之前开发过 Electron 应用,那么你可能接触过 electron-prebuilt 这个 npm 软件包。此软件包几乎是每个 Electron 项目不可或缺的一部分。安装后,它会检测你的操作系统并下载一个预先编译好的二进制文件,该二进制文件已编译并可在你的系统架构上运行。

¥If you've ever worked on an Electron app before, you've likely come across the electron-prebuilt npm package. This package is an indispensable part of nearly every Electron project. When installed, it detects your operating system and downloads a prebuilt binary that is compiled to work on your system's architecture.

新名称

¥The new name

Electron 的安装过程常常是新开发者的绊脚石。许多勇敢的人尝试通过运行 npm install electron 而不是 npm install electron-prebuilt 来开始开发 Electron 应用,结果却发现(通常是在经过一番困惑之后)这并不是他们想要的 electron

¥The Electron installation process was often a stumbling block for new developers. Many brave people tried to get started developing an Electron by app by running npm install electron instead of npm install electron-prebuilt, only to discover (often after much confusion) that it was not the electron they were looking for.

这是因为 npm 上已经有一个 electron 项目,它是在 GitHub 的 Electron 项目存在之前创建的。为了让新开发者更轻松、更直观地进行 Electron 开发,我们联系了现有 electron npm 软件包的所有者,询问他是否愿意让我们使用该名称。幸运的是,他是我们项目的粉丝,并同意帮助我们重新使用这个名字。

¥This was because there was an existing electron project on npm, created before GitHub's Electron project existed. To help make Electron development easier and more intuitive for new developers, we reached out to the owner of the existing electron npm package to ask if he'd be willing to let us use the name. Luckily he was a fan of our project, and agreed to help us repurpose the name.

预构建版本仍在运行

¥Prebuilt lives on

从 1.3.1 版本开始,我们已开始将 electronelectron-prebuilt 软件包同时发布到 npm。这两个包完全相同。我们选择暂时继续以两个名称发布该软件包,以免给目前在其项目中使用 electron-prebuilt 的数千名开发者带来不便。我们建议你更新 package.json 文件以使用新的 electron 依赖,但我们将继续发布 electron-prebuilt 的新版本,直到 2016 年底。

¥As of version 1.3.1, we have begun publishing electron and electron-prebuilt packages to npm in tandem. The two packages are identical. We chose to continue publishing the package under both names for a while so as not to inconvenience the thousands of developers who are currently using electron-prebuilt in their projects. We recommend updating your package.json files to use the new electron dependency, but we will continue releasing new versions of electron-prebuilt until the end of 2016.

electron-userland/electron-prebuilt 仓库将继续作为 electron npm 软件包的规范存储地。

¥The electron-userland/electron-prebuilt repository will remain the canonical home of the electron npm package.

非常感谢

¥Many thanks

我们特别感谢 @mafintosh@maxogden 以及许多其他 contributors 创建和维护 electron-prebuilt,以及他们为 JavaScript、Node.js 和 Electron 社区提供的不懈服务。

¥We owe a special thanks to @mafintosh, @maxogden, and many other contributors for creating and maintaining electron-prebuilt, and for their tireless service to the JavaScript, Node.js, and Electron communities.

感谢 @logicalparadox 允许我们在 npm 上接管 electron 软件包。

¥And thanks to @logicalparadox for allowing us to take over the electron package on npm.

更新你的项目

¥Updating your projects

我们已与社区合作,更新了受此更改影响的常用软件包。electron-packagerelectron-rebuildelectron-builder 等软件包已更新,可以使用新名称,同时继续支持旧名称。

¥We've worked with the community to update popular packages that are affected by this change. Packages like electron-packager, electron-rebuild, and electron-builder have already been updated to work with the new name while continuing to support the old name.

如果你在安装此新软件包时遇到任何问题,请在 electron-userland/electron-prebuilt 代码库中提交问题告知我们。

¥If you encounter any problems installing this new package, please let us know by opening an issue on the electron-userland/electron-prebuilt repository.

如需解决 Electron 的任何其他问题,请使用 electron/electron 代码库。

¥For any other issues with Electron, please use the electron/electron repository.