Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

启动错误 #6

Open
freedomlang opened this issue May 31, 2016 · 11 comments
Open

启动错误 #6

freedomlang opened this issue May 31, 2016 · 11 comments

Comments

@freedomlang
Copy link

错误信息如下

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'browser-window'
    at Module._resolveFilename (module.js:438:15)
    at Function.Module._resolveFilename (/usr/local/lib/node_modules/electron-prebuilt/dist/resources/electron.asar/common/reset-search-paths.js:47:12)
    at Function.Module._load (module.js:386:25)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/root/wxbot/index.js:1:100)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)

是我的electron的安装问题?BTW:electron的版本是1.2

@fritx
Copy link
Owner

fritx commented Jun 2, 2016

@freedomlang 噢 不好意思 可能是electronv1.x 开始废弃旧的用法了 你可以改用0.x版本
http://electron.atom.io/docs/
或者尝试一下对index.js&preload.js 做如下修改

require('app')
require('browser-window')
require('clipboard')
require('native-image')
// =>
require('electron').app
require('electron').BrowserWindow
require('electron').clipboard
require('electron').nativeImage

@freedomlang
Copy link
Author

@fritx 按照官方的api说明修改后,可以启动了。但是,画面卡在登录成功的界面,并没有成功跳转微信客户端的界面。会不会连preload都变了?
https://github.com/electron/electron/blob/master/docs/api/process.md#event-loaded

@fritx
Copy link
Owner

fritx commented Jun 5, 2016

是这个 http://electron.atom.io/docs/api/browser-window/
webPreferences: { nodeIntegration, preload } 似乎还没变
不过可能正式废弃了旧写法 改驼峰试试?

@fritx fritx added the bug label Jun 5, 2016
@fritx
Copy link
Owner

fritx commented Jun 6, 2016

👍 参照commit: huangruichang/md-editor@08ad699
cc @huangruichang

@freedomlang
Copy link
Author

@fritx 还是不行,就是跳转不了!问题还是在preload.js那里。以下是修改的地方!
index.js

var app = require('electron').app
var BrowserWindow = require('electron').BrowserWindow
var ipc = require('electron').ipcRenderer

webPreferences: {
            nodeIntegration: false,
            preload: __dirname + '/preload.js'
        }

win.loadURL('https://wx.qq.com/?lang=zh_CN&t=' + Date.now())

preload.js

var clipboard = require('electron').clipboard
var NativeImage = require('electron').nativeImage
var ipc = require('electron').ipcRenderer

PS:终端没有任何提示!

@huangruichang
Copy link
Collaborator

amazing 👍

@freedomlang
Copy link
Author

freedomlang commented Jun 6, 2016

诡异的是:我翻了一下官方的文档,发现有process.type这一属性。我把这个属性设置成browser就可以跳转了,但是终端还是没有提示!

我在init函数的开头添加alert测试了一下,是有反映的!是不是下面挂掉了?

window._console = window.console

function debug(/*args*/){
    var args = JSON.stringify(_.toArray(arguments))
    _console.log(args)
}

fritx added a commit that referenced this issue Jul 2, 2016
@fritx
Copy link
Owner

fritx commented Jul 2, 2016

@freedomlang OK了

@freedomlang
Copy link
Author

@fritx 还是不跳转>_<,微信上点击登录了,但网页上还停留在提示“在手机上确认登录的画面”!

@fritx
Copy link
Owner

fritx commented Jul 5, 2016

怪了。。我上周末是ok的。。electron v1.2.5

@freedomlang
Copy link
Author

freedomlang commented Jul 5, 2016

@fritx 测试系统是Linux && electron 1.2.0。我在preload.js 的开头加上process.type="browser" 就可以进去了,但是自动回复功能有问题,终端提示回复了,但界面直接卡死了。从手机看也没有发现有自动回复过!

@fritx fritx added the fixed label Nov 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants