Skip to content

wechaty-puppet-mock would failed with Cannot read property 'version' on first run #31

Open
@suntong

Description

@suntong

The wechaty-puppet-mock would failed with Cannot read property 'version' on first run.

Here is the detailed log:

$ WECHATY_PUPPET=wechaty-puppet-mock node examples/starter-bot.js
16:33:12 INFO Wechaty <wechaty-puppet-mock>(wechaty) start() v0.27.60 is starting...
16:33:12 INFO PuppetManager install(wechaty-puppet-mock@^0.15.5) please wait ...
npm: npm

npm: + [email protected]
added 19 packages from 21 contributors and audited 25 packages in 1.017s

npm: found 0 vulnerabilities


16:33:14 INFO PuppetManager install(wechaty-puppet-mock@^0.15.5) 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/node_modules/wechaty/dist/src/puppet-manager.js:89:82
16:33:14 ERR Wechaty start() exception: Cannot read property 'version' of undefined
16:33:14 ERR StarterBot TypeError: Cannot read property 'version' of undefined
  • When run the 2nd time, it will be fine.
  • It will happen (again) when a new module is added into the node_modules directory, it seems.

Don't know if it is specific to wechaty-puppet-mock or it is underlying wechaty modules wechaty/dist/src/puppet-manager.js though, as I can't test online.

PS. my env:

$ npm ls --depth=0 
. . . 
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

$ node --version
v12.9.1

$ lsb_release -a 
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions