wechat-jssdk
wechat-jssdk copied to clipboard
TypeError: Wechat is not a constructor
Hi, I found this repo from Medium post. Great job!
However, after I checkout master repo I got follow Error, could you please help?
PS C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend> npm start
[email protected] start C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend node ./bin/www
C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend\app.js:30 const wx = new Wechat(wechatConfig); ^
TypeError: Wechat is not a constructor at Object.
(C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend\app.js:30:12) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Module.require (internal/modules/cjs/loader.js:1026:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend\bin\www:7:11) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: node ./bin/www
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! C:\Users\xxxx\AppData\Roaming\npm-cache_logs\2020-07-19T08_03_03_260Z-debug.log PS C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend> npm -v 6.14.5 PS C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend> node -v v12.18.2 PS C:\Users\xxxx\Documents\GitHub\wechat_programs\WeChat-JSSDK-Backend> npm run Lifecycle scripts included in wechat-demo: start node ./bin/www
available via
npm run-script
: dev nodemon ./bin/www
Is this coming from the version of nodejs and npm? I am using the latest version as below: npm: 6.14.5 node: v12.18.2
Thanks
The medium post was a little bit old, pls check out the readme here in the repo:
const {Wechat} = require('wechat-jssdk');
const wx = new Wechat(wechatConfig);