简体   繁体   English

在Linux / macOS上安装Electronic时出现问题

[英]Problem installing electron on Linux/macOS

i need to create an app using Angular and Electron. 我需要使用Angular和Electron创建一个应用程序。 This app should work on Windows/macOs and Linux. 这个应用程式应该可以在Windows / macOs和Linux上运作。

I tried to run it on Windows and it worked. 我试图在Windows上运行它,但它正常工作。 But when i try on macOS or Linux, it fails... 但是当我尝试使用macOS或Linux时,它会失败...

Here is the output when i run with npm run electron : 这是我用npm run electron运行时的输出:

Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
    at Object.<anonymous> (/usr/lib/node_modules/electron/index.js:9:9)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/node_modules/electron/cli.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! open-terminal@0.0.0 electron: `ng build --base-href ./ && electron .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the open-terminal@0.0.0 electron script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

In my package.json i created "electron": "ng build --base-href ./ && electron ." 在我的package.json中,我创建了"electron": "ng build --base-href ./ && electron ." to run my app. 运行我的应用程序。

I tried to delete and re install, but it failed.. I tried to reinstall with : sudo npm install electron --verbose 我尝试删除并重新安装,但失败了。.我尝试使用以下sudo npm install electron --verbose重新安装: sudo npm install electron --verbose

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@3.0.10 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@3.0.10 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Build instructions for electron on linux, macOS and windows are different. 在linux,macOS和Windows上电子版的构建说明不同。 To build for linux, as per the electron docs, follow these steps: 按照电子文档为Linux构建,请遵循以下步骤:


1. Make sure you have python 2.7.x installed on your system. 1.确保系统上安装了python2.7.x。 You can check the version of python running on your os by running the command python -V . 您可以通过运行命令python -V检查操作系统上运行的python -V

2. Install nodejs. 2.安装nodejs。 You can download the installer from here. 您可以从此处下载安装程序

3. Since you've not mentioned the version of linux you're running, I'm assuming you're running Ubuntu. 3.由于您没有提到您正在运行的linux版本,因此我假设您正在运行Ubuntu。 Install the following packages. 安装以下软件包。

sudo apt-get install build-essential clang libdbus-1-dev libgtk-3-dev \
                   libnotify-dev libgnome-keyring-dev libgconf2-dev \
                   libasound2-dev libcap-dev libcups2-dev libxtst-dev \
                   libxss1 libnss3-dev gcc-multilib g++-multilib curl \
                   gperf bison python-dbusmock 

These were the very basic required steps to build electron on linux. 这些是在Linux上构建电子版的基本步骤。 You may need to install several other packages depending your system architecture, project dependencies etc. 您可能需要安装其他几个软件包,具体取决于您的系统架构,项目依赖性等。


For complete build instructions, follow the electron docs. 有关完整的构建说明,请遵循电子文档。 Here I leave you with some links. 在这里,我为您提供一些链接。

1. Build Instructions for linux 1. Linux的构建说明

2. Build Instructions for macOS 2. macOS的构建说明

3. Build Instructions for windows 3. Windows的构建说明

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

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