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

Question: How to pre-set puppet module to be used by wechaty with docker #1478

Closed
windmemory opened this issue Jul 13, 2018 · 23 comments
Closed
Labels

Comments

@windmemory
Copy link
Member

Description

I have a bot file in the context folder, and I did npm install wechaty-puppet-padchat inside the folder, then I start the docker running my bot file. Here is my script for running docker:

docker run -t \\
--name="name" \\
-e WECHATY_PUPPET_PADCHAT_TOKEN="token" \\
-e ID="id" \\
-e WECHATY_LOG="silly" \\
-e TZ="Asia/Shanghai" \\
-e WECHATY_PUPPET="padchat" \\
-e NODE_ENV="production" \\
--net=host -v /etc/localtime:/etc/localtime:ro \\
--volume="$(pwd)":/bot \\
--restart=always \\
zixia/wechaty:latest src/index.ts &> /var/log/docker_manage.log)

The script in docker will look for wechaty-puppet-padchat then find nothing, thus start installing the wechaty-puppet-padchat. This is happening every time I started or restarted the docker, and I need to wait for a long time. So I would like to know how to make the wechaty-puppet-padchat pre-installed, then I don't need to wait wechaty to download that for me.

Provide Your Network Information

  1. Where is the location of your server?
    Beijing
  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using?
    AWS

Run npm run doctor or wechaty run doctor(for docker user), paste output here

 __        __        _           _          
 \ \      / /__  ___| |__   __ _| |_ _   _  
  \ \ /\ / / _ \/ __| '_ \ / _` | __| | | | 
   \ V  V /  __/ (__| | | | (_| | |_| |_| | 
    \_/\_/ \___|\___|_| |_|\__,_|\__|\__, | 
                                     |___/  
____________________________________________________
            https://www.chatie.io
  ____                            _   _             
 / ___|___  _ __  _ __   ___  ___| |_(_)_ __   __ _ 
| |   / _ \| '_ \| '_ \ / _ \/ __| __| | '_ \ / _` |
| |__| (_) | | | | | | |  __/ (__| |_| | | | | (_| |
 \____\___/|_| |_|_| |_|\___|\___|\__|_|_| |_|\__, |
                                              |___/ 
  ____ _           _   ____        _       
 / ___| |__   __ _| |_| __ )  ___ | |_ ___ 
| |   | '_ \ / _` | __|  _ \ / _ \| __/ __|
| |___| | | | (_| | |_| |_) | (_) | |_\__ \
 \____|_| |_|\__,_|\__|____/ \___/ \__|___/
                                           
3 WECHATY Environment Variables:
WECHATY_LOG=silly
WECHATY_PUPPET_PADCHAT_TOKEN=token
WECHATY_DOCKER=1

Starting Wechaty v0.19.9 with Node.js v10.6.0 ...

> wechaty@0.19.9 doctor /wechaty
> npm run check-node-version && ts-node bin/doctor


> wechaty@0.19.9 check-node-version /wechaty
> check-node-version --node ">= 10"

10:05:23 SILL Config WECHATY_LOG set level to silly
10:05:23 INFO Config registering process.on("unhandledRejection") for development/debug
10:05:23 VERB Config constructor()
10:05:24 SILL Accessory #0<Wechaty> constructor()
10:05:24 VERB Wechaty contructor()
10:05:24 VERB MemoryCard constructor(default)
10:05:24 VERB StateSwitch constructor(name=Wechaty)
10:05:24 VERB Doctor constructor()
10:05:24 VERB Doctor testTcp()
10:05:24 SILL Doctor testTcp() client connected

  #### Wechaty Doctor

  1. Wechaty version: #git[a4900c1]
  2. Linux x64 version 4.9.87-linuxkit-aufs memory 320/1998 MB
  3. Docker: true
  4. Node version: v10.6.0
  5. Tcp IPC TEST: PASS

  
10:05:24 SILL Doctor testTcp() server closed

 __        __        _           _          
 \ \      / /__  ___| |__   __ _| |_ _   _  
  \ \ /\ / / _ \/ __| '_ \ / _` | __| | | | 
   \ V  V /  __/ (__| | | | (_| | |_| |_| | 
    \_/\_/ \___|\___|_| |_|\__,_|\__|\__, | 
                                     |___/  
____________________________________________________
            https://www.chatie.io
  _____      _ _      ___   
 | ____|_  _(_) |_   / _ \  
 |  _| \ \/ / | __| | | | | 
 | |___ >  <| | |_  | |_| | 
 |_____/_/\_\_|\__|  \___/  
                            

Expected behavior

Docker run the bot without downloading the wechaty-puppet-padchat

Actual behavior

Docker run the bot, wechaty detect there is no wechaty-puppet-padchat, then install the dependency

Steps to reproduce the behavior (and fixes, if any)

In the same folder, run ts-node bot.ts LOG:

Show Logs

Paste the full output logs here with WECHATY_LOG=silly set

# PASTE FULL LOG OUTPUT AT HERE:


 __        __        _           _          
 \ \      / /__  ___| |__   __ _| |_ _   _  
  \ \ /\ / / _ \/ __| '_ \ / _` | __| | | | 
   \ V  V /  __/ (__| | | | (_| | |_| |_| | 
    \_/\_/ \___|\___|_| |_|\__,_|\__|\__, | 
                                     |___/  
____________________________________________________
            https://www.chatie.io
  ____                            _   _             
 / ___|___  _ __  _ __   ___  ___| |_(_)_ __   __ _ 
| |   / _ \| '_ \| '_ \ / _ \/ __| __| | '_ \ / _` |
| |__| (_) | | | | | | |  __/ (__| |_| | | | | (_| |
 \____\___/|_| |_|_| |_|\___|\___|\__|_|_| |_|\__, |
                                              |___/ 
  ____ _           _   ____        _       
 / ___| |__   __ _| |_| __ )  ___ | |_ ___ 
| |   | '_ \ / _` | __|  _ \ / _ \| __/ __|
| |___| | | | (_| | |_| |_) | (_) | |_\__ \
 \____|_| |_|\__,_|\__|____/ \___/ \__|___/
                                           
5 WECHATY Environment Variables:
WECHATY_PUPPET=padchat
WECHATY_PUPPET_PADCHAT_ENDPOINT=ws://54.223.36.77:8080/wx
WECHATY_LOG=silly
WECHATY_PUPPET_PADCHAT_TOKEN=5b2ceecc2104fc59dc2a3201
WECHATY_DOCKER=1

Starting Wechaty v0.19.4 with Node.js v10.6.0 ...
Working directory: /bot
Please make sure you had installed all the NPM modules which is depended on your bot script.
Executing ts-node src/index.ts
18:20:04 SILL Config WECHATY_LOG set level to silly
18:20:04 INFO Config registering process.on("unhandledRejection") for development/debug
18:20:04 SILL Config WECHATY_LOG set level to silly
18:20:04 INFO Config registering process.on("unhandledRejection") for development/debug
18:20:04 VERB Config constructor()
18:20:05 SILL Accessory #0<Wechaty> constructor()
18:20:05 VERB Wechaty contructor()
18:20:05 VERB MemoryCard constructor(5b2ceecc2104fc59dc2a3201)
18:20:05 VERB StateSwitch constructor(name=Wechaty)
18:20:05 VERB Wechaty on(scan, function) registered
18:20:05 VERB Wechaty onFunction(scan)
18:20:05 VERB Wechaty on(login, function) registered
18:20:05 VERB Wechaty onFunction(login)
18:20:05 VERB Wechaty on(logout, function) registered
18:20:05 VERB Wechaty onFunction(logout)
18:20:05 VERB Wechaty on(error, function) registered
18:20:05 VERB Wechaty onFunction(error)
18:20:05 VERB Wechaty on(room-join, function) registered
18:20:05 VERB Wechaty onFunction(room-join)
18:20:05 VERB Wechaty on(friendship, function) registered
18:20:05 VERB Wechaty onFunction(friendship)
18:20:05 VERB Wechaty on(message, function) registered
18:20:05 VERB Wechaty onFunction(message)
18:20:05 SILL Wechaty version() form development environment is not availble: ENOENT: no such file or directory, stat '/wechaty/dist/.git'
18:20:05 INFO Wechaty <padchat> start() v0.19.4 is starting...
18:20:05 VERB Wechaty puppet: padchat
18:20:05 VERB Wechaty profile: 5b2ceecc2104fc59dc2a3201
18:20:05 VERB Wechaty id: cjjjtzigs00000qnsmmkbk5r3
18:20:05 SILL StateSwitch <Wechaty> on() is false
18:20:05 SILL StateSwitch <Wechaty> on() is false
18:20:05 VERB StateSwitch <Wechaty> on(pending) <- (false)
18:20:05 VERB MemoryCard load() file: /bot/5b2ceecc2104fc59dc2a3201.memory-card.json
18:20:05 INFO Listening on port 39567 
18:20:05 VERB Wechaty initPuppet() padchat
18:20:05 VERB Wechaty initPuppetResolver(padchat)
18:20:05 VERB MemoryCard sub(padchat)
18:20:05 VERB MemoryCard static sub(MemoryCard<5b2ceecc2104fc59dc2a3201>, padchat)
18:20:05 VERB MemoryCard constructor(5b2ceecc2104fc59dc2a3201)
18:20:05 VERB PuppetConfig puppetResolver(padchat)
18:20:05 SILL PuppetConfig puppetResolver(padchat) exception: Cannot find module 'wechaty-puppet-padchat'
18:20:05 INFO PuppetConfig installPuppet(wechaty-puppet-padchat@^0.8.1) please wait ...
@huan
Copy link
Member

huan commented Jul 13, 2018

The solution is very simple:

run npm install wechaty-puppet-padchat before you start docker.

The Wechaty will look for the puppet module that it required. If the module had been already installed with the right version, then it will use it directly so that there will be no necessity to run install.

Please try my suggestion, and let me know if it will solve your problem, thanks.

@huan huan added the question label Jul 13, 2018
@windmemory
Copy link
Member Author

By right version, you mean the version in the puppet-config.ts file? Does the version need to be exactly the same as the one in the config file?

@windmemory
Copy link
Member Author

I tried npm install wechaty-puppet-padchat before I open this issue, it doesn't work. And I just tried to install the specific version wechaty-puppet-padchat@0.8.1, also doesn't work.

To give a more specific description:
I ran the docker script inside the project root folder, and npm i wechaty-pyppet-padchat was also ran in the project root. And as you can see, in the script, I mounted the project root folder to the /bot folder inside docker. Theoretically, it should work and wechaty-config should be able to find the puppet, but for some weird reason, it couldn't. Do you know where I did wrong in the process?

Thanks in advance for the help :)

@huan
Copy link
Member

huan commented Jul 13, 2018

That's wired, maybe it related with the Docker settings.

Could you please help me to confirm whether this happens when you are not using Docker?

@huan huan added bug and removed question labels Jul 13, 2018
@huan
Copy link
Member

huan commented Jul 13, 2018

Confirmed this is a BUG when using Docker.

@windmemory
Copy link
Member Author

@zixia I tried without Docker, it works, so I believe there is something wrong with Docker or docker settings.

@huan
Copy link
Member

huan commented Jul 14, 2018

Thanks.

You are right this bug is related the Docker. I will look into it later.

Currently, I believe you can use the following code as a workaround:

import { PuppetPadchat } from 'wechaty-puppet-padchat'
const puppet = new PuppetPadchat()
const bot = new Wechaty({ puppet })

This will load wechaty-puppet-padchat from your current working directory(which is /bot in the docker container), and it will pass the puppet instance to Wechaty so that Wechaty could be able to use it.

In Docker, the problem is: the wechaty module is not in /bot/node_modules/ directory, it is in /node_modules/ directory in root, which is a symlink to /wechaty/.

So every time Wechaty try to load wechaty-puppet-padchat, it will only be able to look into /wechaty/node_modules/ and of course there's no wechaty-puppet-padchat over there at all, no matter whether you install it in /bot/node_modules/ or not.

@huan
Copy link
Member

huan commented Jul 14, 2018

Trying to fix Docker Image by setting NODE_PATH

See Also

@windmemory
Copy link
Member Author

Thanks for the explanation, that makes sense.

And I tried the NODE_PATH solution, it does not work for my case. I added below command inside the docker start command

-e NODE_PATH="/bot/node_modules/"

Please correct me if I am doing this wrong.

I thought if I run my bot in my bot folder, wechaty is a dependency of my bot, so it should load the dependency from /bot/node_modules/, why npm tries to get the dependency from /wechaty/node_modules/? This is the part that stuck me from finding out the solution, could you explain a little more about the start process of the docker image? Why does it behave different from the normal installed packages? Is this because of the npm link?

I tried to get into docker and see where the wechaty-puppet-padchat get installed, seems like it is not in /node_modules/, but in /wechaty/node_modules, this is weird to me. If the node_modules is a symlink to /wechaty/node_modules, then wechaty-puppet-padchat should be able to be found in /node_modules/. Anyway, this is just weird, but not really related to the issue.

@windmemory
Copy link
Member Author

Oh, I didn't check the latest commit related to this issue, seems like I don't need to put NODE_PATH variable into the argument. I will try to run the latest docker image again and see whether it works.

@huan
Copy link
Member

huan commented Jul 14, 2018

My last commit did not work yet.

Please use the workaround before I fix it.

@huan
Copy link
Member

huan commented Jul 14, 2018

Update: TypeScript does not support NODE_PATH

See: microsoft/TypeScript#8760

huan added a commit that referenced this issue Jul 14, 2018
@huan
Copy link
Member

huan commented Jul 14, 2018

@windmemory Could you please try the v0.19.14 or above to see if this bug had been fixed?

@windmemory
Copy link
Member Author

Hi @zixia , thanks for fixing this, I tried v0.19.14, not work for me, here is the log:

 __        __        _           _          
 \ \      / /__  ___| |__   __ _| |_ _   _  
  \ \ /\ / / _ \/ __| '_ \ / _` | __| | | | 
   \ V  V /  __/ (__| | | | (_| | |_| |_| | 
    \_/\_/ \___|\___|_| |_|\__,_|\__|\__, | 
                                     |___/  
____________________________________________________
            https://www.chatie.io
  ____                            _   _             
 / ___|___  _ __  _ __   ___  ___| |_(_)_ __   __ _ 
| |   / _ \| '_ \| '_ \ / _ \/ __| __| | '_ \ / _` |
| |__| (_) | | | | | | |  __/ (__| |_| | | | | (_| |
 \____\___/|_| |_|_| |_|\___|\___|\__|_|_| |_|\__, |
                                              |___/ 
  ____ _           _   ____        _       
 / ___| |__   __ _| |_| __ )  ___ | |_ ___ 
| |   | '_ \ / _` | __|  _ \ / _ \| __/ __|
| |___| | | | (_| | |_| |_) | (_) | |_\__ \
 \____|_| |_|\__,_|\__|____/ \___/ \__|___/
                                           
WECHATY Environment Variables: 5
WECHATY_PUPPET=padchat
WECHATY_PUPPET_PADCHAT_ENDPOINT=ws://54.223.36.77:8080/wx
WECHATY_LOG=silly
WECHATY_PUPPET_PADCHAT_TOKEN=5a951e6d7d2a7860ccf86ce0
WECHATY_DOCKER=1

Starting Docker Container for Wechaty v0.19.14 with Node.js v10.6.0 ...
Working directory: /bot
Please make sure you had installed all the NPM modules which is depended on your bot script.
/node_modules/@babel exists
/node_modules/@types exists
'/node_modules/abstract-error' -> '/bot/node_modules/abstract-error'
'/node_modules/abstract-iterator' -> '/bot/node_modules/abstract-iterator'
'/node_modules/abstract-leveldown' -> '/bot/node_modules/abstract-leveldown'
'/node_modules/abstract-nosql' -> '/bot/node_modules/abstract-nosql'
'/node_modules/abstract-object' -> '/bot/node_modules/abstract-object'
/node_modules/accepts exists
'/node_modules/acorn' -> '/bot/node_modules/acorn'
'/node_modules/acorn-jsx' -> '/bot/node_modules/acorn-jsx'
'/node_modules/address' -> '/bot/node_modules/address'
'/node_modules/agent-base' -> '/bot/node_modules/agent-base'
'/node_modules/agentkeepalive' -> '/bot/node_modules/agentkeepalive'
/node_modules/ajv exists
'/node_modules/ajv-keywords' -> '/bot/node_modules/ajv-keywords'
'/node_modules/ali-oss' -> '/bot/node_modules/ali-oss'
'/node_modules/ansi-escapes' -> '/bot/node_modules/ansi-escapes'
/node_modules/ansi-regex exists
/node_modules/ansi-styles exists
'/node_modules/any-promise' -> '/bot/node_modules/any-promise'
'/node_modules/app-root-path' -> '/bot/node_modules/app-root-path'
'/node_modules/aproba' -> '/bot/node_modules/aproba'
'/node_modules/are-we-there-yet' -> '/bot/node_modules/are-we-there-yet'
/node_modules/argparse exists
/node_modules/array-flatten exists
'/node_modules/array-union' -> '/bot/node_modules/array-union'
'/node_modules/array-uniq' -> '/bot/node_modules/array-uniq'
/node_modules/arrify exists
/node_modules/asn1 exists
/node_modules/assert-plus exists
'/node_modules/ast-types' -> '/bot/node_modules/ast-types'
/node_modules/async exists
/node_modules/async-limiter exists
/node_modules/asynckit exists
/node_modules/aws-sign2 exists
/node_modules/aws4 exists
'/node_modules/axios' -> '/bot/node_modules/axios'
/node_modules/babel-code-frame exists
/node_modules/balanced-match exists
/node_modules/bcrypt-pbkdf exists
'/node_modules/bignumber.js' -> '/bot/node_modules/bignumber.js'
'/node_modules/bindings' -> '/bot/node_modules/bindings'
'/node_modules/bl' -> '/bot/node_modules/bl'
/node_modules/bluebird exists
'/node_modules/bmp-js' -> '/bot/node_modules/bmp-js'
/node_modules/body-parser exists
'/node_modules/bowser' -> '/bot/node_modules/bowser'
/node_modules/brace-expansion exists
/node_modules/brolog exists
'/node_modules/bson' -> '/bot/node_modules/bson'
'/node_modules/buffer-alloc' -> '/bot/node_modules/buffer-alloc'
'/node_modules/buffer-alloc-unsafe' -> '/bot/node_modules/buffer-alloc-unsafe'
'/node_modules/buffer-codec' -> '/bot/node_modules/buffer-codec'
'/node_modules/buffer-equal' -> '/bot/node_modules/buffer-equal'
'/node_modules/buffer-fill' -> '/bot/node_modules/buffer-fill'
/node_modules/buffer-from exists
'/node_modules/buffer-shims' -> '/bot/node_modules/buffer-shims'
/node_modules/builtin-modules exists
'/node_modules/builtin-status-codes' -> '/bot/node_modules/builtin-status-codes'
/node_modules/bytes exists
/node_modules/caller-path exists
/node_modules/callsites exists
/node_modules/camelcase exists
'/node_modules/can-promise' -> '/bot/node_modules/can-promise'
/node_modules/caseless exists
/node_modules/chalk exists
'/node_modules/chardet' -> '/bot/node_modules/chardet'
'/node_modules/chownr' -> '/bot/node_modules/chownr'
'/node_modules/circular-json' -> '/bot/node_modules/circular-json'
'/node_modules/cli-cursor' -> '/bot/node_modules/cli-cursor'
'/node_modules/cli-width' -> '/bot/node_modules/cli-width'
/node_modules/cliui exists
/node_modules/co exists
'/node_modules/co-defer' -> '/bot/node_modules/co-defer'
'/node_modules/co-gather' -> '/bot/node_modules/co-gather'
'/node_modules/co-priority-queue' -> '/bot/node_modules/co-priority-queue'
'/node_modules/co-thread' -> '/bot/node_modules/co-thread'
'/node_modules/code-point-at' -> '/bot/node_modules/code-point-at'
/node_modules/color-convert exists
/node_modules/color-name exists
/node_modules/colors exists
/node_modules/combined-stream exists
/node_modules/commander exists
/node_modules/concat-map exists
'/node_modules/concat-stream' -> '/bot/node_modules/concat-stream'
'/node_modules/console-control-strings' -> '/bot/node_modules/console-control-strings'
/node_modules/content-disposition exists
/node_modules/content-type exists
/node_modules/cookie exists
/node_modules/cookie-signature exists
'/node_modules/copy-to' -> '/bot/node_modules/copy-to'
/node_modules/core-js exists
/node_modules/core-util-is exists
'/node_modules/cron-parser' -> '/bot/node_modules/cron-parser'
/node_modules/cross-spawn exists
/node_modules/cuid exists
'/node_modules/custom-ability' -> '/bot/node_modules/custom-ability'
'/node_modules/custom-factory' -> '/bot/node_modules/custom-factory'
'/node_modules/cycle' -> '/bot/node_modules/cycle'
'/node_modules/d' -> '/bot/node_modules/d'
/node_modules/dashdash exists
'/node_modules/data-uri-to-buffer' -> '/bot/node_modules/data-uri-to-buffer'
'/node_modules/dateformat' -> '/bot/node_modules/dateformat'
/node_modules/debug exists
/node_modules/decamelize exists
'/node_modules/decompress-response' -> '/bot/node_modules/decompress-response'
/node_modules/deep-extend exists
'/node_modules/deep-is' -> '/bot/node_modules/deep-is'
'/node_modules/default-user-agent' -> '/bot/node_modules/default-user-agent'
'/node_modules/deferred-leveldown' -> '/bot/node_modules/deferred-leveldown'
/node_modules/define-properties exists
'/node_modules/degenerator' -> '/bot/node_modules/degenerator'
'/node_modules/del' -> '/bot/node_modules/del'
/node_modules/delayed-stream exists
'/node_modules/delegates' -> '/bot/node_modules/delegates'
/node_modules/depd exists
/node_modules/destroy exists
'/node_modules/detect-libc' -> '/bot/node_modules/detect-libc'
/node_modules/diff exists
'/node_modules/digest-header' -> '/bot/node_modules/digest-header'
'/node_modules/dijkstrajs' -> '/bot/node_modules/dijkstrajs'
/node_modules/doctrine exists
'/node_modules/dom-walk' -> '/bot/node_modules/dom-walk'
/node_modules/ecc-jsbn exists
/node_modules/ee-first exists
/node_modules/encodeurl exists
'/node_modules/encoding-down' -> '/bot/node_modules/encoding-down'
'/node_modules/end-of-stream' -> '/bot/node_modules/end-of-stream'
'/node_modules/end-or-error' -> '/bot/node_modules/end-or-error'
/node_modules/err-code exists
'/node_modules/errno' -> '/bot/node_modules/errno'
/node_modules/error-ex exists
'/node_modules/es5-ext' -> '/bot/node_modules/es5-ext'
'/node_modules/es6-iterator' -> '/bot/node_modules/es6-iterator'
'/node_modules/es6-promise' -> '/bot/node_modules/es6-promise'
'/node_modules/es6-promisify' -> '/bot/node_modules/es6-promisify'
'/node_modules/es6-symbol' -> '/bot/node_modules/es6-symbol'
/node_modules/escape-html exists
/node_modules/escape-string-regexp exists
'/node_modules/escodegen' -> '/bot/node_modules/escodegen'
'/node_modules/eslint' -> '/bot/node_modules/eslint'
'/node_modules/eslint-scope' -> '/bot/node_modules/eslint-scope'
'/node_modules/eslint-visitor-keys' -> '/bot/node_modules/eslint-visitor-keys'
'/node_modules/espree' -> '/bot/node_modules/espree'
/node_modules/esprima exists
'/node_modules/esquery' -> '/bot/node_modules/esquery'
'/node_modules/esrecurse' -> '/bot/node_modules/esrecurse'
'/node_modules/estraverse' -> '/bot/node_modules/estraverse'
/node_modules/esutils exists
/node_modules/etag exists
'/node_modules/events-ex' -> '/bot/node_modules/events-ex'
'/node_modules/execa' -> '/bot/node_modules/execa'
'/node_modules/exif-parser' -> '/bot/node_modules/exif-parser'
'/node_modules/expand-template' -> '/bot/node_modules/expand-template'
/node_modules/express exists
/node_modules/extend exists
'/node_modules/external-editor' -> '/bot/node_modules/external-editor'
/node_modules/extsprintf exists
'/node_modules/eyes' -> '/bot/node_modules/eyes'
/node_modules/fast-deep-equal exists
'/node_modules/fast-future' -> '/bot/node_modules/fast-future'
/node_modules/fast-json-stable-stringify exists
'/node_modules/fast-levenshtein' -> '/bot/node_modules/fast-levenshtein'
'/node_modules/figures' -> '/bot/node_modules/figures'
'/node_modules/file-entry-cache' -> '/bot/node_modules/file-entry-cache'
'/node_modules/file-type' -> '/bot/node_modules/file-type'
'/node_modules/file-uri-to-path' -> '/bot/node_modules/file-uri-to-path'
/node_modules/finalhandler exists
/node_modules/find-up exists
'/node_modules/flash-store' -> '/bot/node_modules/flash-store'
'/node_modules/flat-cache' -> '/bot/node_modules/flat-cache'
'/node_modules/follow-redirects' -> '/bot/node_modules/follow-redirects'
/node_modules/for-each exists
/node_modules/foreach exists
/node_modules/forever-agent exists
/node_modules/form-data exists
/node_modules/forwarded exists
/node_modules/fresh exists
'/node_modules/fs-constants' -> '/bot/node_modules/fs-constants'
/node_modules/fs-extra exists
/node_modules/fs.realpath exists
'/node_modules/ftp' -> '/bot/node_modules/ftp'
'/node_modules/functional-red-black-tree' -> '/bot/node_modules/functional-red-black-tree'
'/node_modules/gauge' -> '/bot/node_modules/gauge'
'/node_modules/get-caller-file' -> '/bot/node_modules/get-caller-file'
'/node_modules/get-ready' -> '/bot/node_modules/get-ready'
'/node_modules/get-stream' -> '/bot/node_modules/get-stream'
'/node_modules/get-uri' -> '/bot/node_modules/get-uri'
/node_modules/getpass exists
'/node_modules/github-from-package' -> '/bot/node_modules/github-from-package'
/node_modules/glob exists
'/node_modules/global' -> '/bot/node_modules/global'
/node_modules/globals exists
'/node_modules/globby' -> '/bot/node_modules/globby'
/node_modules/graceful-fs exists
/node_modules/har-schema exists
/node_modules/har-validator exists
/node_modules/has-ansi exists
/node_modules/has-flag exists
'/node_modules/has-unicode' -> '/bot/node_modules/has-unicode'
'/node_modules/hoek' -> '/bot/node_modules/hoek'
/node_modules/hosted-git-info exists
/node_modules/http-errors exists
'/node_modules/http-proxy-agent' -> '/bot/node_modules/http-proxy-agent'
/node_modules/http-signature exists
'/node_modules/https-proxy-agent' -> '/bot/node_modules/https-proxy-agent'
'/node_modules/humanize-ms' -> '/bot/node_modules/humanize-ms'
/node_modules/iconv-lite exists
'/node_modules/ignore' -> '/bot/node_modules/ignore'
'/node_modules/imurmurhash' -> '/bot/node_modules/imurmurhash'
/node_modules/inflight exists
/node_modules/inherits exists
'/node_modules/inherits-ex' -> '/bot/node_modules/inherits-ex'
/node_modules/ini exists
'/node_modules/inquirer' -> '/bot/node_modules/inquirer'
'/node_modules/install' -> '/bot/node_modules/install'
'/node_modules/invert-kv' -> '/bot/node_modules/invert-kv'
'/node_modules/ip' -> '/bot/node_modules/ip'
'/node_modules/ip-regex' -> '/bot/node_modules/ip-regex'
/node_modules/ipaddr.js exists
/node_modules/is-arrayish exists
/node_modules/is-buffer exists
/node_modules/is-builtin-module exists
/node_modules/is-callable exists
'/node_modules/is-class' -> '/bot/node_modules/is-class'
'/node_modules/is-fullwidth-code-point' -> '/bot/node_modules/is-fullwidth-code-point'
'/node_modules/is-function' -> '/bot/node_modules/is-function'
'/node_modules/is-nan' -> '/bot/node_modules/is-nan'
'/node_modules/is-path-cwd' -> '/bot/node_modules/is-path-cwd'
'/node_modules/is-path-in-cwd' -> '/bot/node_modules/is-path-in-cwd'
'/node_modules/is-path-inside' -> '/bot/node_modules/is-path-inside'
'/node_modules/is-promise' -> '/bot/node_modules/is-promise'
'/node_modules/is-resolvable' -> '/bot/node_modules/is-resolvable'
'/node_modules/is-stream' -> '/bot/node_modules/is-stream'
'/node_modules/is-type-of' -> '/bot/node_modules/is-type-of'
/node_modules/is-typedarray exists
/node_modules/isarray exists
'/node_modules/isemail' -> '/bot/node_modules/isemail'
/node_modules/isexe exists
/node_modules/isstream exists
'/node_modules/jimp' -> '/bot/node_modules/jimp'
'/node_modules/joi' -> '/bot/node_modules/joi'
'/node_modules/jpeg-js' -> '/bot/node_modules/jpeg-js'
/node_modules/js-tokens exists
/node_modules/js-yaml exists
/node_modules/jsbn exists
/node_modules/json-parse-better-errors exists
'/node_modules/json-rpc-peer' -> '/bot/node_modules/json-rpc-peer'
'/node_modules/json-rpc-protocol' -> '/bot/node_modules/json-rpc-protocol'
/node_modules/json-schema exists
/node_modules/json-schema-traverse exists
'/node_modules/json-stable-stringify-without-jsonify' -> '/bot/node_modules/json-stable-stringify-without-jsonify'
/node_modules/json-stringify-safe exists
/node_modules/jsonfile exists
/node_modules/jsprim exists
'/node_modules/jsqr' -> '/bot/node_modules/jsqr'
'/node_modules/jstoxml' -> '/bot/node_modules/jstoxml'
'/node_modules/lcid' -> '/bot/node_modules/lcid'
'/node_modules/level-codec' -> '/bot/node_modules/level-codec'
'/node_modules/level-errors' -> '/bot/node_modules/level-errors'
'/node_modules/level-iterator-stream' -> '/bot/node_modules/level-iterator-stream'
'/node_modules/levelup' -> '/bot/node_modules/levelup'
'/node_modules/levn' -> '/bot/node_modules/levn'
'/node_modules/load-bmfont' -> '/bot/node_modules/load-bmfont'
/node_modules/load-json-file exists
/node_modules/locate-path exists
/node_modules/lodash exists
'/node_modules/long-timeout' -> '/bot/node_modules/long-timeout'
/node_modules/lru-cache exists
/node_modules/make-error exists
/node_modules/media-typer exists
'/node_modules/mem' -> '/bot/node_modules/mem'
/node_modules/merge-descriptors exists
/node_modules/methods exists
/node_modules/mime exists
/node_modules/mime-db exists
/node_modules/mime-types exists
'/node_modules/mimic-fn' -> '/bot/node_modules/mimic-fn'
'/node_modules/mimic-response' -> '/bot/node_modules/mimic-response'
'/node_modules/min-document' -> '/bot/node_modules/min-document'
/node_modules/minimatch exists
/node_modules/minimist exists
/node_modules/mkdirp exists
'/node_modules/moment' -> '/bot/node_modules/moment'
'/node_modules/moment-timezone' -> '/bot/node_modules/moment-timezone'
'/node_modules/mongodb' -> '/bot/node_modules/mongodb'
'/node_modules/mongodb-core' -> '/bot/node_modules/mongodb-core'
/node_modules/ms exists
'/node_modules/mute-stream' -> '/bot/node_modules/mute-stream'
'/node_modules/mz' -> '/bot/node_modules/mz'
'/node_modules/nan' -> '/bot/node_modules/nan'
'/node_modules/natural-compare' -> '/bot/node_modules/natural-compare'
/node_modules/negotiator exists
'/node_modules/netmask' -> '/bot/node_modules/netmask'
'/node_modules/next-tick' -> '/bot/node_modules/next-tick'
'/node_modules/node-abi' -> '/bot/node_modules/node-abi'
'/node_modules/node-expat' -> '/bot/node_modules/node-expat'
'/node_modules/node-schedule' -> '/bot/node_modules/node-schedule'
'/node_modules/noop-logger' -> '/bot/node_modules/noop-logger'
/node_modules/nop exists
/node_modules/normalize-package-data exists
'/node_modules/nosql-leveldb' -> '/bot/node_modules/nosql-leveldb'
/node_modules/npm exists
'/node_modules/npm-run-path' -> '/bot/node_modules/npm-run-path'
'/node_modules/npmlog' -> '/bot/node_modules/npmlog'
'/node_modules/number-is-nan' -> '/bot/node_modules/number-is-nan'
/node_modules/oauth-sign exists
'/node_modules/object-assign' -> '/bot/node_modules/object-assign'
/node_modules/object-keys exists
/node_modules/on-finished exists
/node_modules/once exists
'/node_modules/onetime' -> '/bot/node_modules/onetime'
'/node_modules/optionator' -> '/bot/node_modules/optionator'
'/node_modules/os-homedir' -> '/bot/node_modules/os-homedir'
'/node_modules/os-locale' -> '/bot/node_modules/os-locale'
'/node_modules/os-name' -> '/bot/node_modules/os-name'
'/node_modules/os-tmpdir' -> '/bot/node_modules/os-tmpdir'
'/node_modules/osx-release' -> '/bot/node_modules/osx-release'
'/node_modules/p-finally' -> '/bot/node_modules/p-finally'
/node_modules/p-limit exists
/node_modules/p-locate exists
/node_modules/p-try exists
'/node_modules/pac-proxy-agent' -> '/bot/node_modules/pac-proxy-agent'
'/node_modules/pac-resolver' -> '/bot/node_modules/pac-resolver'
'/node_modules/parse-bmfont-ascii' -> '/bot/node_modules/parse-bmfont-ascii'
'/node_modules/parse-bmfont-binary' -> '/bot/node_modules/parse-bmfont-binary'
'/node_modules/parse-bmfont-xml' -> '/bot/node_modules/parse-bmfont-xml'
'/node_modules/parse-headers' -> '/bot/node_modules/parse-headers'
/node_modules/parse-json exists
/node_modules/parseurl exists
/node_modules/path-exists exists
/node_modules/path-is-absolute exists
'/node_modules/path-is-inside' -> '/bot/node_modules/path-is-inside'
/node_modules/path-key exists
/node_modules/path-parse exists
/node_modules/path-to-regexp exists
/node_modules/path-type exists
/node_modules/performance-now exists
/node_modules/pify exists
'/node_modules/pinkie' -> '/bot/node_modules/pinkie'
'/node_modules/pinkie-promise' -> '/bot/node_modules/pinkie-promise'
'/node_modules/pixelmatch' -> '/bot/node_modules/pixelmatch'
'/node_modules/platform' -> '/bot/node_modules/platform'
'/node_modules/pluralize' -> '/bot/node_modules/pluralize'
'/node_modules/pngjs' -> '/bot/node_modules/pngjs'
'/node_modules/prebuild-install' -> '/bot/node_modules/prebuild-install'
'/node_modules/prelude-ls' -> '/bot/node_modules/prelude-ls'
'/node_modules/process' -> '/bot/node_modules/process'
/node_modules/process-nextick-args exists
/node_modules/progress exists
/node_modules/promise-retry exists
/node_modules/proxy-addr exists
'/node_modules/proxy-agent' -> '/bot/node_modules/proxy-agent'
'/node_modules/proxy-from-env' -> '/bot/node_modules/proxy-from-env'
'/node_modules/prr' -> '/bot/node_modules/prr'
/node_modules/pseudomap exists
'/node_modules/pump' -> '/bot/node_modules/pump'
/node_modules/punycode exists
/node_modules/qr-image exists
'/node_modules/qrcode' -> '/bot/node_modules/qrcode'
/node_modules/qrcode-terminal exists
/node_modules/qs exists
/node_modules/range-parser exists
/node_modules/raw-body exists
/node_modules/rc exists
'/node_modules/read-chunk' -> '/bot/node_modules/read-chunk'
/node_modules/read-pkg exists
/node_modules/read-pkg-up exists
/node_modules/readable-stream exists
/node_modules/regenerator-runtime exists
'/node_modules/regexpp' -> '/bot/node_modules/regexpp'
/node_modules/request exists
'/node_modules/request-promise' -> '/bot/node_modules/request-promise'
'/node_modules/request-promise-core' -> '/bot/node_modules/request-promise-core'
'/node_modules/require-directory' -> '/bot/node_modules/require-directory'
'/node_modules/require-main-filename' -> '/bot/node_modules/require-main-filename'
'/node_modules/require-uncached' -> '/bot/node_modules/require-uncached'
'/node_modules/require_optional' -> '/bot/node_modules/require_optional'
/node_modules/resolve exists
/node_modules/resolve-from exists
'/node_modules/restore-cursor' -> '/bot/node_modules/restore-cursor'
/node_modules/retry exists
'/node_modules/rimraf' -> '/bot/node_modules/rimraf'
'/node_modules/run-async' -> '/bot/node_modules/run-async'
'/node_modules/rx-lite' -> '/bot/node_modules/rx-lite'
'/node_modules/rx-lite-aggregates' -> '/bot/node_modules/rx-lite-aggregates'
/node_modules/rx-queue exists
/node_modules/rxjs exists
/node_modules/safe-buffer exists
/node_modules/safer-buffer exists
/node_modules/sax exists
'/node_modules/sdk-base' -> '/bot/node_modules/sdk-base'
/node_modules/semver exists
/node_modules/send exists
/node_modules/serve-static exists
'/node_modules/set-blocking' -> '/bot/node_modules/set-blocking'
/node_modules/setprototypeof exists
/node_modules/shebang-command exists
/node_modules/shebang-regex exists
'/node_modules/signal-exit' -> '/bot/node_modules/signal-exit'
'/node_modules/simple-concat' -> '/bot/node_modules/simple-concat'
'/node_modules/simple-get' -> '/bot/node_modules/simple-get'
'/node_modules/slice-ansi' -> '/bot/node_modules/slice-ansi'
'/node_modules/smart-buffer' -> '/bot/node_modules/smart-buffer'
'/node_modules/socks' -> '/bot/node_modules/socks'
'/node_modules/socks-proxy-agent' -> '/bot/node_modules/socks-proxy-agent'
'/node_modules/sorted-array-functions' -> '/bot/node_modules/sorted-array-functions'
/node_modules/source-map exists
/node_modules/spdx-correct exists
/node_modules/spdx-exceptions exists
/node_modules/spdx-expression-parse exists
/node_modules/spdx-license-ids exists
/node_modules/sprintf-js exists
/node_modules/sshpk exists
/node_modules/stack-trace exists
/node_modules/state-switch exists
/node_modules/statuses exists
'/node_modules/stealthy-require' -> '/bot/node_modules/stealthy-require'
'/node_modules/stream-http' -> '/bot/node_modules/stream-http'
'/node_modules/stream-to' -> '/bot/node_modules/stream-to'
'/node_modules/stream-to-buffer' -> '/bot/node_modules/stream-to-buffer'
'/node_modules/string-width' -> '/bot/node_modules/string-width'
/node_modules/string_decoder exists
/node_modules/strip-ansi exists
/node_modules/strip-bom exists
'/node_modules/strip-eof' -> '/bot/node_modules/strip-eof'
/node_modules/strip-json-comments exists
/node_modules/supports-color exists
'/node_modules/table' -> '/bot/node_modules/table'
'/node_modules/tar-fs' -> '/bot/node_modules/tar-fs'
'/node_modules/tar-stream' -> '/bot/node_modules/tar-stream'
'/node_modules/text-table' -> '/bot/node_modules/text-table'
'/node_modules/thenify' -> '/bot/node_modules/thenify'
'/node_modules/thenify-all' -> '/bot/node_modules/thenify-all'
/node_modules/through exists
'/node_modules/thunkify' -> '/bot/node_modules/thunkify'
'/node_modules/tinycolor2' -> '/bot/node_modules/tinycolor2'
'/node_modules/tmp' -> '/bot/node_modules/tmp'
'/node_modules/to-arraybuffer' -> '/bot/node_modules/to-arraybuffer'
'/node_modules/to-buffer' -> '/bot/node_modules/to-buffer'
'/node_modules/topo' -> '/bot/node_modules/topo'
/node_modules/tough-cookie exists
'/node_modules/trim' -> '/bot/node_modules/trim'
/node_modules/tslib exists
/node_modules/tslint exists
/node_modules/tslint-config-standard exists
/node_modules/tslint-eslint-rules exists
/node_modules/tsutils exists
/node_modules/tunnel-agent exists
/node_modules/tweetnacl exists
'/node_modules/type-check' -> '/bot/node_modules/type-check'
/node_modules/type-is exists
'/node_modules/typedarray' -> '/bot/node_modules/typedarray'
/node_modules/typescript exists
/node_modules/universalify exists
/node_modules/unpipe exists
'/node_modules/url-regex' -> '/bot/node_modules/url-regex'
'/node_modules/urllib' -> '/bot/node_modules/urllib'
/node_modules/util-deprecate exists
'/node_modules/util-ex' -> '/bot/node_modules/util-ex'
'/node_modules/utility' -> '/bot/node_modules/utility'
/node_modules/utils-merge exists
/node_modules/uuid exists
/node_modules/validate-npm-package-license exists
/node_modules/vary exists
/node_modules/verror exists
'/node_modules/wechaty-puppet-padchat' -> '/bot/node_modules/wechaty-puppet-padchat'
/node_modules/which exists
'/node_modules/which-module' -> '/bot/node_modules/which-module'
'/node_modules/which-pm-runs' -> '/bot/node_modules/which-pm-runs'
'/node_modules/wide-align' -> '/bot/node_modules/wide-align'
'/node_modules/win-release' -> '/bot/node_modules/win-release'
'/node_modules/window-or-global' -> '/bot/node_modules/window-or-global'
'/node_modules/winston' -> '/bot/node_modules/winston'
/node_modules/wordwrap exists
'/node_modules/wrap-ansi' -> '/bot/node_modules/wrap-ansi'
/node_modules/wrappy exists
'/node_modules/write' -> '/bot/node_modules/write'
/node_modules/ws exists
'/node_modules/xhr' -> '/bot/node_modules/xhr'
'/node_modules/xml-parse-from-string' -> '/bot/node_modules/xml-parse-from-string'
/node_modules/xml2js exists
'/node_modules/xml2json' -> '/bot/node_modules/xml2json'
/node_modules/xmlbuilder exists
'/node_modules/xregexp' -> '/bot/node_modules/xregexp'
'/node_modules/xtend' -> '/bot/node_modules/xtend'
'/node_modules/y18n' -> '/bot/node_modules/y18n'
/node_modules/yallist exists
/node_modules/yargs exists
'/node_modules/yargs-parser' -> '/bot/node_modules/yargs-parser'
Executing ts-node src/index.ts
14:08:05 SILL Config WECHATY_LOG set level to silly
14:08:05 INFO Config registering process.on("unhandledRejection") for development/debug
14:08:06 SILL Config WECHATY_LOG set level to silly
14:08:06 INFO Config registering process.on("unhandledRejection") for development/debug
14:08:06 VERB Config constructor()
14:08:07 SILL Accessory #0<Wechaty> constructor()
14:08:07 VERB Wechaty contructor()
14:08:07 VERB MemoryCard constructor(5a951e6d7d2a7860ccf86ce0)
14:08:07 VERB StateSwitch constructor(name=Wechaty)
14:08:07 VERB Wechaty on(scan, function) registered
14:08:07 VERB Wechaty onFunction(scan)
14:08:07 VERB Wechaty on(login, function) registered
14:08:07 VERB Wechaty onFunction(login)
14:08:07 VERB Wechaty on(logout, function) registered
14:08:07 VERB Wechaty onFunction(logout)
14:08:07 VERB Wechaty on(error, function) registered
14:08:07 VERB Wechaty onFunction(error)
14:08:07 VERB Wechaty on(room-join, function) registered
14:08:07 VERB Wechaty onFunction(room-join)
14:08:07 VERB Wechaty on(friendship, function) registered
14:08:07 VERB Wechaty onFunction(friendship)
14:08:07 VERB Wechaty on(message, function) registered
14:08:07 VERB Wechaty onFunction(message)
14:08:07 SILL Wechaty version() form development environment is not availble: ENOENT: no such file or directory, stat '/wechaty/dist/.git'
14:08:07 INFO Wechaty <padchat> start() v0.19.14 is starting...
14:08:07 VERB Wechaty puppet: padchat
14:08:07 VERB Wechaty profile: 5a951e6d7d2a7860ccf86ce0
14:08:07 VERB Wechaty id: cjjnvb182000085nsyyalw5d7
14:08:07 SILL StateSwitch <Wechaty> on() is false
14:08:07 SILL StateSwitch <Wechaty> on() is false
14:08:07 VERB StateSwitch <Wechaty> on(pending) <- (false)
14:08:07 VERB MemoryCard load() file: /bot/5a951e6d7d2a7860ccf86ce0.memory-card.json
14:08:07 INFO Listening on port 59586 
14:08:07 VERB Wechaty initPuppet() padchat
14:08:07 VERB Wechaty initPuppetResolver(padchat)
14:08:07 VERB MemoryCard sub(padchat)
14:08:07 VERB MemoryCard static sub(MemoryCard<5a951e6d7d2a7860ccf86ce0>, padchat)
14:08:07 VERB MemoryCard constructor(5a951e6d7d2a7860ccf86ce0)
14:08:07 VERB PuppetConfig puppetResolver(padchat)
14:08:07 SILL PuppetConfig puppetResolver(padchat) exception: The module '/bot/node_modules/node-expat/build/Release/node_expat.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
14:08:07 INFO PuppetConfig installPuppet(wechaty-puppet-padchat@^0.8.1) please wait ...

I saw

PuppetConfig puppetResolver(padchat) exception: The module '/bot/node_modules/node-expat/build/Release/node_expat.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

Is this related to the issue? Do I need to use a specifig version of node to make this works?

@huan
Copy link
Member

huan commented Jul 16, 2018

Good News

14:08:07 VERB Wechaty initPuppet() padchat
14:08:07 VERB Wechaty initPuppetResolver(padchat)
14:08:07 VERB MemoryCard sub(padchat)

According to the above log message, the Docker can load your padchat without any problem.

Bad News

PuppetConfig puppetResolver(padchat) exception: The module '/bot/node_modules/node-expat/build/Release/node_expat.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

You have to use Node v10 when you run npm install outside of the Docker.

Please try again with node 10, and let me know if it works for you.

@huan
Copy link
Member

huan commented Jul 16, 2018

Conclusion

import { PuppetPadchat } from 'wechaty-puppet-padchat'
const puppet = new PuppetPadchat()
const bot = new Wechaty({ puppet })

The above code should be the best practice when you want to use a pre-installed puppet for Wechaty.

Use the node_modules directory which is installed outside of the docker might caused other problems like a version mismatch for Node.js.

@huan
Copy link
Member

huan commented Jul 18, 2018

@windmemory Could you confirm that the best practice can solve your problem?

import { PuppetPadchat } from 'wechaty-puppet-padchat'
const puppet = new PuppetPadchat()
const bot = new Wechaty({ puppet })

If there still have any problem, please let me know by reply this thread.

BTW: I'll disable link modules to the global function, so please do not use it any more.

@windmemory
Copy link
Member Author

I think it should be okay, but I saw this error when I am passing a puppet in the option of wechaty

Error: unsupported options.puppet: Puppet#0<PuppetPadchat>()/PuppetPadchat#0
    at Wechaty.<anonymous> (/Users/yuangao/git/wechaty/wechaty/src/wechaty.ts:557:13)
    at Generator.next (<anonymous>)
    at /Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:3:12)
    at Wechaty.initPuppetResolver (/Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:349:16)
    at Wechaty.<anonymous> (/Users/yuangao/git/wechaty/wechaty/src/wechaty.ts:486:31)
    at Generator.next (<anonymous>)
    at /Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:3:12)
    at Wechaty.initPuppet (/Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:312:16)
    at Wechaty.<anonymous> (/Users/yuangao/git/wechaty/wechaty/src/wechaty.ts:807:18)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/yuangao/git/wechaty/wechaty/dist/src/wechaty.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/bin.ts:141:12)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Could you please help me with this issue?

@huan
Copy link
Member

huan commented Jul 18, 2018

Need More Information

In order to help us to find the problem out, you should provide all the detail information about the issue. Please make sure you are following the ISSUE Template, answer all the question, and the more important: provide the steps to reproduce the problem.

@windmemory
Copy link
Member Author

Node version: v10.4.1
Here is my bot.ts file:

import { Wechaty } from 'wechaty';
import { generate } from 'qrcode-terminal';
import { PuppetPadchat } from 'wechaty-puppet-padchat';
const puppet = new PuppetPadchat({
  endpoint: 'someEndpoing',
  token: 'someToken',
});
const bot = new Wechaty({ puppet });
bot
.on('scan', (qrcode, status) => {
  generate(qrcode, { small: true })

  const qrcodeImageUrl = [
    'https://api.qrserver.com/v1/create-qr-code/?data=',
    encodeURIComponent(qrcode),
  ].join('')

  console.log(`[${status}] ${qrcodeImageUrl}\nScan QR Code above to log in: `)
})
.on('login', async user => console.log(`Login: ${user}`))
.on('message',  message => console.log(`Message: ${message}`))
.start()  

And I have installed wechaty, wechaty-puppet-padchat and also qrcode-terminal in my local folder.

Then I did a

ts-node bot.ts

After, I saw the error message above.

Have you tried with the code you put in the comment? If so, could you please share the whole bot file?

@huan
Copy link
Member

huan commented Jul 19, 2018

I can run your code with a new /tmp/x directory with npm init -y

zixia@sg:/tmp/x$ cat bot.ts 
import { Wechaty } from 'wechaty';
import { generate } from 'qrcode-terminal';
import { PuppetPadchat } from 'wechaty-puppet-padchat';
const puppet = new PuppetPadchat({
  endpoint: 'someEndpoing',
  token: 'someToken',
});
const bot = new Wechaty({ puppet });
bot
.on('scan', (qrcode, status) => {
  generate(qrcode, { small: true })

  const qrcodeImageUrl = [
    'https://api.qrserver.com/v1/create-qr-code/?data=',
    encodeURIComponent(qrcode),
  ].join('')

  console.log(`[${status}] ${qrcodeImageUrl}\nScan QR Code above to log in: `)
})
.on('login', async user => console.log(`Login: ${user}`))
.on('message',  message => console.log(`Message: ${message}`))
.start()  
zixia@sg:/tmp/x$ WECHATY_LOG=silly ./node_modules/.bin/ts-node bot.ts                                               
01:04:18 SILL Config WECHATY_LOG set level to silly
01:04:18 INFO Config registering process.on("unhandledRejection") for development/debug
01:04:18 VERB Config constructor()
01:04:20 VERB Puppet constructor({"timeout":240,"endpoint":"someEndpoing","token":"someToken"}) #0
01:04:20 VERB StateSwitch constructor(name=PuppetPadchat)
01:04:20 VERB MemoryCard constructor()
01:04:20 VERB Puppet constructor() watchdog timeout set to 240 seconds
01:04:20 VERB HotImport callerResolve(., /tmp/x/node_modules/wechaty-puppet/dist/src/puppet.js)
01:04:20 SILL HotImport callerResolve() callsites() file=/tmp/x/node_modules/hot-import/dist/src/hot-import.js, type=Object
01:04:20 SILL HotImport callerResolve() callsites() file=/tmp/x/node_modules/wechaty-puppet/dist/src/puppet.js, type=null
01:04:20 SILL HotImport callerResolve() callsites() file=/tmp/x/node_modules/wechaty-puppet-padchat/dist/src/puppet-padchat.js, type=null
01:04:20 SILL HotImport callerResolve() callerFile=/tmp/x/node_modules/wechaty-puppet-padchat/dist/src/puppet-padchat.js
01:04:20 VERB Puppet constructor() childClassPath=/tmp/x/node_modules/wechaty-puppet-padchat/dist/src
01:04:20 SILL Accessory #0<Wechaty> constructor()
01:04:20 VERB Wechaty contructor()
01:04:20 VERB MemoryCard constructor(default)
01:04:20 VERB StateSwitch constructor(name=Wechaty)
01:04:20 VERB Wechaty on(scan, function) registered
01:04:20 VERB Wechaty onFunction(scan)
01:04:20 VERB Wechaty on(login, function) registered
01:04:20 VERB Wechaty onFunction(login)
01:04:20 VERB Wechaty on(message, function) registered
01:04:20 VERB Wechaty onFunction(message)
01:04:20 SILL Wechaty version() form development environment is not availble: ENOENT: no such file or directory, stat '/tmp/x/node_modules/wechaty/dist/.git'
01:04:20 INFO Wechaty <Puppet#0<PuppetPadchat>()/PuppetPadchat#0> start() v0.18.5 is starting...
01:04:20 VERB Wechaty puppet: Puppet#0<PuppetPadchat>()/PuppetPadchat#0
01:04:20 VERB Wechaty profile: default
01:04:20 VERB Wechaty id: cjjrurx9p00009974pye8lou1
01:04:20 SILL StateSwitch <Wechaty> on() is false
01:04:20 SILL StateSwitch <Wechaty> on() is false
01:04:20 VERB StateSwitch <Wechaty> on(pending) <- (false)
01:04:20 VERB MemoryCard load() file: /tmp/x/default.memory-card.json
01:04:20 VERB MemoryCard load() file not exist, NOOP
01:04:20 VERB Wechaty initPuppet() Puppet#0<PuppetPadchat>()/PuppetPadchat#0
01:04:20 VERB Wechaty initPuppetResolver(Puppet#0<PuppetPadchat>()/PuppetPadchat#0)
01:04:20 VERB MemoryCard sub(Puppet#0<PuppetPadchat>()/PuppetPadchat#0)
01:04:20 VERB MemoryCard static sub(MemoryCard<default>, Puppet#0<PuppetPadchat>()/PuppetPadchat#0)
01:04:20 VERB MemoryCard constructor(default)
01:04:20 VERB Puppet setMemory()
01:04:20 INFO Wechaty initPuppet() inited puppet: Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0
01:04:20 VERB Wechaty initPuppetVersionSatisfy(Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0)
01:04:20 VERB Wechaty initPuppetSemverSatisfy(*)
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(login) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(logout) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(message) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(scan) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(dong) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(error) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(reset) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(start) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(stop) registered
01:04:20 VERB Wechaty initPuppetEventBridge() puppet.on(watchdog) registered
01:04:20 VERB Wechaty initAccessory(Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0)
01:04:20 SILL Accessory <Contact> static set wechaty = "Wechaty#cjjrurx9p00009974pye8lou1<Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0>(default)"
01:04:20 SILL Accessory <ContactSelf> static set wechaty = "Wechaty#cjjrurx9p00009974pye8lou1<Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0>(default)"
01:04:20 SILL Accessory <Friendship> static set wechaty = "Wechaty#cjjrurx9p00009974pye8lou1<Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0>(default)"
01:04:20 SILL Accessory <Message> static set wechaty = "Wechaty#cjjrurx9p00009974pye8lou1<Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0>(default)"
01:04:20 SILL Accessory <Room> static set wechaty = "Wechaty#cjjrurx9p00009974pye8lou1<Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0>(default)"
01:04:20 SILL Accessory <Contact> static set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 SILL Accessory <ContactSelf> static set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 SILL Accessory <Friendship> static set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 SILL Accessory <Message> static set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 SILL Accessory <Room> static set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 SILL Accessory <Wechaty> set puppet = "Puppet#0<PuppetPadchat>(default)/PuppetPadchat#0"
01:04:20 VERB PuppetPadchat start() with default
01:04:20 SILL StateSwitch <PuppetPadchat> on() is false
01:04:20 SILL StateSwitch <PuppetPadchat> on() is false
01:04:20 VERB StateSwitch <PuppetPadchat> on(pending) <- (false)
01:04:20 VERB PadchatRpc constructor(someEndpoing, someToken)
01:04:20 VERB PuppetPadchatManager constructor()
01:04:20 VERB PuppetPadchat startManager()
01:04:20 SILL StateSwitch <PuppetPadchat> off() is false
01:04:20 VERB PuppetPadchatManager start()
01:04:20 VERB PadchatRpc start()
01:04:20 VERB PadchatRpc initWebSocket()
01:04:20 WARN PuppetPadchatManager start() super.start() exception: Error: Invalid URL: someEndpoing
01:04:20 VERB PadchatRpc stop()
01:04:20 VERB PadchatRpc stopQueues()
01:04:20 WARN PadchatRpc stop() subscript not exist
01:04:20 WARN PadchatRpc stop() no socket
01:04:21 WARN PuppetPadchatManager start() super.start() retry now ...
01:04:21 VERB PadchatRpc start()
01:04:21 VERB PadchatRpc initWebSocket()
01:04:21 WARN PuppetPadchatManager start() super.start() exception: Error: Invalid URL: someEndpoing
01:04:21 VERB PadchatRpc stop()
01:04:21 VERB PadchatRpc stopQueues()
01:04:21 WARN PadchatRpc stop() subscript not exist
01:04:21 WARN PadchatRpc stop() no socket
^C
zixia@sg:/tmp/x$ ls -l
total 116
-rw-r--r--   1 zixia root    680 Jul 19 00:57 bot.ts
drwxrwxr-x 307 zixia zixia 12288 Jul 19 01:03 node_modules
-rw-r--r--   1 zixia zixia   392 Jul 19 01:03 package.json
-rw-rw-r--   1 zixia zixia 95237 Jul 19 01:03 package-lock.json

@windmemory
Copy link
Member Author

windmemory commented Jul 20, 2018

Okay, seems works for me. But I would like to point out that the node version need to be the same as the one in the docker, otherwise it might complains that PuppetPadchat is not an instance of Puppet.

This issue is okay to be closed.

@huan
Copy link
Member

huan commented Jul 20, 2018

Glad to hear that you get your code worked, cheers.

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

No branches or pull requests

2 participants