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

run on windows.error #75

Closed
issmile opened this issue Nov 4, 2016 · 5 comments
Closed

run on windows.error #75

issmile opened this issue Nov 4, 2016 · 5 comments

Comments

@issmile
Copy link

issmile commented Nov 4, 2016

code:

const Wechaty = require('wechaty')

Wechaty.instance() // Singleton
.on('scan', (url, code) => console.log(`Scan QrCode to login: ${code}\n${url}`))
.on('login',       user => console.log(`User ${user} logined`))
.on('message',  message => console.log(`Message: ${message}`))
.init()

error:
E:\weixin\wechaty>node mybot.js
E:\weixin\wechaty\mybot.js:3
Wechaty.instance() // Singleton
^

TypeError: Wechaty.instance is not a function
at Object. (E:\weixin\wechaty\mybot.js:3:9)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

how to run it on windows?I am not good English can I say Chinese?

@huan
Copy link
Member

huan commented Nov 4, 2016

Hi, @issmile

Of course, you can speak Chinese, please. :)

According to #40 (comment), you need to change const Wechaty = require('wechaty') like the following diff:

- import Wechaty from 'wechaty'
+ import { Wechaty } from 'wechaty'

Sorry for the misleading old document, I had fixed them today.

@issmile
Copy link
Author

issmile commented Nov 4, 2016

汗,以前都是用的现成的手脚架里有es6环境,现在这个不知道应该怎么弄了.....

E:\weixin\wechaty>node mybot.js
E:\weixin\wechaty\mybot.js:1
(function (exports, require, module, __filename, __dirname) { import {Wechaty} f
rom 'wechaty'
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

额,我安装了
package.json了
{
"dependencies": {
"wechaty": "^0.5.1",
"babel-core": "^6.0.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.0.0",
"babel-plugin-transform-runtime": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.0.0",
"babel-register": "^6.0.0",
"babel-runtime": "^6.0.0"
},
"devDependencies": {
"babel-cli": "^6.18.0"
}
}

@huan
Copy link
Member

huan commented Nov 4, 2016

No problem, you are almost there!

in order to use js, use const Wechaty = require('wechaty') then all will be ok.

@issmile
Copy link
Author

issmile commented Nov 5, 2016

终于搞定了es6,然后现在是这样的error 是什么情况?
E:\weixin\wechaty>npm run dev

weixinbot@1.0.0 dev E:\weixin\wechaty
babel-node ./src/mybot.js

INFO Wechaty v0.5.0 initializing...
[7588:15908:1105/175418:ERROR:mf_helpers.cc(12)] Error
in dxva_video_decode_accelerator_win.cc on line 345
WARN PuppetWebBrowserDriver getChromeDriver() exception
: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:52667, re
try: 0
WARN PuppetWebBrowserDriver getChromeDriver() with retr
y: 1
E:\weixin\wechaty\node_modules.3.0.0@selenium-webdrive
r\lib\promise.js:2497
throw error;
^

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:5266
7
at ClientRequest. (E:\weixin\wechaty\nod
e_modules.3.0.0@selenium-webdriver\http\index.js:238:1
5)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:306:
9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tic
k.js:74:11)
at process._tickDomainCallback (internal/process/ne
xt_tick.js:122:9)
From: Task: WebDriver.createSession()
at Function.createSession (E:\weixin\wechaty\node_m
odules.3.0.0@selenium-webdriver\lib\webdriver.js:776:2
4)
at Function.createSession (E:\weixin\wechaty\node_m
odules.3.0.0@selenium-webdriver\chrome.js:709:29)
at createDriver (E:\weixin\wechaty\node_modules.3.
0.0@selenium-webdriver\index.js:167:33)
at Builder.build (E:\weixin\wechaty\node_modules.3
.0.0@selenium-webdriver\index.js:639:16)
at BrowserDriver. (E:\weixin\wechaty\nod
e_modules.0.5.1@wechaty\src\puppet-web\browser-driver.
ts:131:24)
at next (native)
at E:\weixin\wechaty\node_modules.0.5.1@wechaty\di
st\src\puppet-web\browser-driver.js:7:65
at new Promise (E:\weixin\wechaty\node_modules.2.4
.1@core-js\modules\es6.promise.js:191:7)
at __awaiter (E:\weixin\wechaty\node_modules.0.5.1
@wechaty\dist\src\puppet-web\browser-driver.js:3:12)
at BrowserDriver.getChromeDriver (E:\weixin\wechaty
\node_modules.0.5.1@wechaty\dist\src\puppet-web\browse
r-driver.js:65:16)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "E:\Program Files\nodejs\node.exe" "E:
\Program Files\nodejs\node_modules\npm\bin\npm-cl
i.js" "run" "dev"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! weixinbot@1.0.0 dev: babel-node ./src/mybot.j s
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weixinbot@1.0.0 dev script 'babe
l-node ./src/mybot.js'.
npm ERR! Make sure you have the latest version of node.
js and npm installed.
npm ERR! If you do, this is most likely a problem with
the weixinbot package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system
:
npm ERR! babel-node ./src/mybot.js
npm ERR! You can get information on how to open an issu
e for this project with:
npm ERR! npm bugs weixinbot
npm ERR! Or if that isn't available, you can get their
info via:
npm ERR! npm owner ls weixinbot
npm ERR! There is likely additional logging output abov
e.

npm ERR! Please include the following file with any sup
port request:
npm ERR! E:\weixin\wechaty\npm-debug.log

@huan
Copy link
Member

huan commented Nov 6, 2016

@issmile Please submit a new ISSUE for your new problem, and fill all the required questions in the ISSUE template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants