docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Error running Wechaty on Gitpod

Open sbis04 opened this issue 3 years ago • 5 comments

Running the Ding Dong bot on Gitpod from the link given in the Quick Start page under Tutorials gives error. Have added the entire console output below:

Click to expand this section to see the console output with the error
> [email protected] start:wechat:web /workspace/wechaty-getting-started
> cross-env WECHATY_LOG=verbose WECHATY_PUPPET=wechaty-puppet-wechat npm start


> [email protected] start /workspace/wechaty-getting-started
> ts-node examples/ding-dong-bot.ts

07:39:39 INFO Config registering process.on("unhandledRejection") for development/debug
07:39:39 VERB Config constructor()
07:39:39 ERR Config ###########################
07:39:39 ERR Config uncaughtException: /workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/dist/src/config.js:67
        ?? 'https://api.chatie.io';
         ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/src/client/puppet-service.ts:110:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/src/mod.ts:1:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty/src/io-client.ts:26:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty/src/mod.ts:66:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/examples/ding-dong-bot.ts:5:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module.m._compile (/workspace/wechaty-getting-started/node_modules/ts-node/src/index.ts:1295:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.require.extensions.<computed> [as .ts] (/workspace/wechaty-getting-started/node_modules/ts-node/src/index.ts:1298:12)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at main (/workspace/wechaty-getting-started/node_modules/ts-node/src/bin.ts:246:14)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/ts-node/src/bin.ts:382:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 uncaughtException
07:39:39 ERR Config ###########################
/workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/dist/src/config.js:67
        ?? 'https://api.chatie.io';
         ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/src/client/puppet-service.ts:110:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty-puppet-service/src/mod.ts:1:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty/src/io-client.ts:26:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/wechaty/src/mod.ts:66:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/workspace/wechaty-getting-started/examples/ding-dong-bot.ts:5:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module.m._compile (/workspace/wechaty-getting-started/node_modules/ts-node/src/index.ts:1295:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.require.extensions.<computed> [as .ts] (/workspace/wechaty-getting-started/node_modules/ts-node/src/index.ts:1298:12)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at main (/workspace/wechaty-getting-started/node_modules/ts-node/src/bin.ts:246:14)
    at Object.<anonymous> (/workspace/wechaty-getting-started/node_modules/ts-node/src/bin.ts:382:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ts-node examples/ding-dong-bot.ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gitpod/.npm/_logs/2021-06-04T07_39_39_602Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:wechat:web: `cross-env WECHATY_LOG=verbose WECHATY_PUPPET=wechaty-puppet-wechat npm start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start:wechat:web script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gitpod/.npm/_logs/2021-06-04T07_39_39_620Z-debug.log

Screenshot 2021-06-04 at 1 46 40 PM

I believe it is caused due to some of the node modules, @huan let us know how to fix this.

sbis04 avatar Jun 04 '21 08:06 sbis04

We have some issues with the Wechaty because we switch to the ES target 2020 last week in TypeScript, which requires Node >=14 to support those latest ES features.

Today we have noticed this problem and we have set back to ES target 2019 which will be able to run under Node 12.

Please try the latest wechaty-getting-start repo and it should work without any problem now. (I have just tested it).

huan avatar Jun 04 '21 16:06 huan

Thanks @huan now it's working!

One more issue that I found here is; when I generate the QR code for WhatsApp and try to scan it, WhatsApp couldn't scan the QR code.

Screenshot 2021-06-05 at 6 41 16 AM

How can this be fixed? (I think it's because of the small gaps between the QR segments while it's being displayed in the terminal)

sbis04 avatar Jun 05 '21 01:06 sbis04

Thanks @huan now it's working!

One more issue that I found here is; when I generate the QR code for WhatsApp and try to scan it, WhatsApp couldn't scan the QR code.

Screenshot 2021-06-05 at 6 41 16 AM

How can this be fixed? (I think it's because of the small gaps between the QR segments while it's being displayed in the terminal)

Hii @sbis04 I have scanned the QR code and it worked well. There might be some other issue when you're doing it

shwetalsoni avatar Jun 05 '21 10:06 shwetalsoni

I tried it once again and found something interesting, the QR can be scanned when in the dark mode of Gitpod but in light mode WhatsApp can't pick the QR code.

This works: Screenshot 2021-06-06 at 12 10 36 PM

@shwetalsoni Did you try in the dark mode? If yes, then try once in light mode and let me know if it works.

sbis04 avatar Jun 06 '21 06:06 sbis04

I tried it once again and found something interesting, the QR can be scanned when in the dark mode of Gitpod but in light mode WhatsApp can't pick the QR code.

This works: Screenshot 2021-06-06 at 12 10 36 PM

@shwetalsoni Did you try in the dark mode? If yes, then try once in light mode and let me know if it works.

Yeah, I tried it, it doesn't work on light mode probably because the QR code is not displayed properly in light mode.

shwetalsoni avatar Jun 06 '21 07:06 shwetalsoni