我需要创建一个应用程序使用角度和电子。这个应用程序应该在Windows/macOs和Linux上工作。
我试着在Windows上运行它,它成功了。但当我在macOS或Linux上试用时,它失败了.
下面是我使用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.在我的package.json中,我创建了"electron": "ng build --base-href ./ && electron ."来运行我的应用程序。
我试着删除并重新安装,但是失败了。我尝试用: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.发布于 2018-11-20 13:27:34
在linux上构建电子指令,macOS和windows是不同的。要构建linux,如电子文档所示,请执行以下步骤:
1.确保系统上安装了python2.7.x。您可以通过运行命令python -V来检查运行在操作系统上的python版本。
2.安装nodejs。您可以从这里。下载安装程序。
3.,因为您没有提到您正在运行的linux版本,我假设您正在运行Ubuntu。安装下列软件包。
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 这些是在linux上构建电子所需的基本步骤。您可能需要安装其他几个包,这取决于您的系统架构、项目依赖等。
要获得完整的构建说明,请按照电子文档操作。在这里,我给你留下一些链接。
1. 构建linux指令
2. 构建macOS指令
3. 生成windows的说明
https://stackoverflow.com/questions/53393675
复制相似问题