Open suntong opened 4 years ago
I can not reproduce your result.
Mine is:
$ WECHATY_PUPPET=wechaty-puppet-mock node examples/starter-bot.js
08:46:26 INFO Wechaty <wechaty-puppet-mock>(wechaty) start() v0.27.53 is starting...
08:46:26 INFO StarterBot Cancel(0) - https://api.qrserver.com/v1/create-qr-code/?data=https%3A%2F%2Fnot-exist.com
08:46:26 INFO StarterBot Starter Bot Started.
08:46:26 INFO StarterBot Contact<mock-name> login
08:46:29 INFO StarterBot Message#Text[🗣Contact<mock-name>] mock text
08:46:32 INFO StarterBot Message#Text[🗣Contact<mock-name>] mock text
So I'd like to suggest that you can do a rm -fr node_modules && git pull && npm install
then try again.
- When run the 2nd time, it will be fine.
- It will/might happen (again) when a new module is added ...
So unless you are installing from fresh, (or maybe added a new module), you cannot reproduce it.
I've reproduced it many times like that, the most reliable way to reproduce is to have a brand new wechaty module installation.
Here is another log, from another brand new wechaty module installation:
$ WECHATY_PUPPET=wechaty-puppet-mock node examples/starter-bot.js
19:57:09 INFO PuppetManager install(wechaty-puppet-mock@^0.15.5) done
TypeError: Cannot read property 'version' of undefined
at Object.<anonymous> (/path/to/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-mock/dist/src/config.js:23:23)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/path/to/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-mock/dist/src/puppet-mock.js:35:18)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/path/to/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-mock/dist/src/index.js:6:10)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at /path/to/nodejs/wechaty-getting-started/node_modules/wechaty/dist/src/puppet-manager.js:89:82
19:57:09 ERR Wechaty start() exception: Cannot read property 'version' of undefined
19:57:09 ERR StarterBot TypeError: Cannot read property 'version' of undefined
What do you mean "brand new"?
Please provide the details about which version you had installed, with your re-producible install scripts.
Ok, I guess I had catch it in wechaty package.json files.
I had specified the mock version in it before. Will remove it and publish a new version.
Should be fixed in Wechaty v0.28, please try the latest master branch.
Thanks for reporting this problem!
wechaty-puppet-mock
entirely, but I think it might not work for all cases. I.e., the wechaty-puppet-mock
is not required and normally need to be installed manually, which means re-introducing the wechaty-puppet-mock
entry back to the package.json
. Hmm... maybe not. So...examples/advanced/gist-bot/index.js
, but now everything is OK for me. That's because this issue should have already been fixed.
Please let me know if you have any trouble from the latest master branch code, or Wechaty v0.28 or above.
I get the latest Wechaty v0.28 but am still seeing the problem:
$ WECHATY_PUPPET=wechaty-puppet-mock node examples/advanced/gist-bot/index.js
=============== Powered by Wechaty ===============
-------- https://github.com/Chatie/wechaty --------
Please wait... I'm trying to login in...
14:07:46 INFO Wechaty <wechaty-puppet-mock>() start() v0.28.3 is starting...
14:07:46 INFO PuppetManager install(wechaty-puppet-mock@^0.16.1) please wait ...
npm: + wechaty-puppet-mock@0.16.1
added 48 packages from 37 contributors and audited 94 packages in 2.959s
npm: found 0 vulnerabilities
14:07:50 INFO PuppetManager install(wechaty-puppet-mock@^0.16.1) done
TypeError: Cannot read property 'version' of undefined
at Object.<anonymous> (/path/to/nodejs/node_modules/wechaty-puppet-mock/dist/src/config.js:23:23)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/path/to/nodejs/node_modules/wechaty-puppet-mock/dist/src/puppet-mock.js:35:18)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/path/to/nodejs/node_modules/wechaty-puppet-mock/dist/src/index.js:6:10)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at /path/to/nodejs/wechaty-getting-started/node_modules/wechaty/dist/src/puppet-manager.js:89:82
14:07:50 ERR Wechaty start() exception: Cannot read property 'version' of undefined
14:07:50 INFO Bot error: TypeError: Cannot read property 'version' of undefined
14:07:50 INFO Wechaty <wechaty-puppet-mock> stop() v0.28.3 is stoping ...
14:07:50 WARN Wechaty stop() puppet.stop() exception: static puppet not found for Wechaty, please see issue #1217: https://github.com/Chatie/wechaty/issues/1217
And again, when run for the 2nd time, it is be fine.
Interesting. I'll look in to it later.
The
wechaty-puppet-mock
would failed with Cannot read property 'version' on first run.Here is the detailed log:
node_modules
directory, it seems.Don't know if it is specific to
wechaty-puppet-mock
or it is underlyingwechaty
moduleswechaty/dist/src/puppet-manager.js
though, as I can't test online.PS. my env: