21

我正在用 ES6 重写我的电子应用程序,使用 Laravel Mix 编译应用程序 JS 和 SASS。现在主进程很好地加载了渲染进程。一旦发生这种情况,我的 app.js 就会加载,这就是我遇到问题的地方。所以我这样做:

import { remote } from 'electron';

这导致控制台中出现此错误:

Uncaught Error: Electron failed to install correctly, please delete node_modules/electron and try installing again

现在我尝试重新安装电子,即使电子在主进程启动时工作。该行在编译的js中引用了这个:

/* WEBPACK VAR INJECTION */(function(__dirname) {var fs = __webpack_require__(8)
var path = __webpack_require__(9)

var pathFile = path.join(__dirname, 'path.txt')

if (fs.existsSync(pathFile)) {
  module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
} else {
  throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
}

我不确定发生了什么,任何建议或信息都会有很大帮助!

谢谢

编辑:我试过运行它--verbose

/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 3

2017-06-13 16:10:42.383 Electron Helper[47106:766924] Couldn't set selectedTextBackgroundColor from default ()
4

1 回答 1

0

最可能的问题来源是path.txt不存在。

path.txtelectron从安装时生成npm。如果您在安装时没有看到任何错误,electron这意味着错误将被抑制。

疑难解答:检查是否node_modules/electron/path.txt存在。如果没有,那么你就有问题了。

解决方案:

注意:如果在 Windows 上,请使用本机CMD而不是Git Bash

npm install通过执行以下脚本尝试手动安装电子

cd node_modules/electron && node install.js

这可能需要一段时间,因为它将下载电子的完整包。

于 2017-11-21T18:27:50.377 回答