whatsapp-nodejs
whatsapp-nodejs copied to clipboard
MODULE_NOT_FOUND error when running example whatsapp.test.js
Hi! I'm not able to run the example 'whatsapp.test.js' from the test folder
test> node .\whatsapp.test.js
E:\myproject\whatsapp-nodejs\node_modules\@privacyresearch\curve25519-typescript\lib\built\curveasm.js:136
throw ex;
^
Error: Cannot find module '/etc/whatsapp.json'
Require stack:
- E:\myproject\whatsapp-nodejs\src\config.js
- E:\myproject\whatsapp-nodejs\src\db.js
- E:\myproject\whatsapp-nodejs\src\initBeforeStart.js
- E:\myproject\whatsapp-nodejs\src\Whatsapp.js
- E:\myproject\whatsapp-nodejs\src\index.js
- E:\myproject\whatsapp-nodejs\test\whatsapp.test.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (E:\myproject\whatsapp-nodejs\src\config.js:1:22)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (E:\myproject\whatsapp-nodejs\src\db.js:13:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'E:\\myproject\\whatsapp-nodejs\\src\\config.js',
'E:\\myproject\\whatsapp-nodejs\\src\\db.js',
'E:\\myproject\\whatsapp-nodejs\\src\\initBeforeStart.js',
'E:\\myproject\\whatsapp-nodejs\\src\\Whatsapp.js',
'E:\\myproject\\whatsapp-nodejs\\src\\index.js',
'E:\\myproject\\whatsapp-nodejs\\test\\whatsapp.test.js'
]
}
I just changed the file to send the SMS code only to my number
const { Whatsapp, WhatsappServer } = require('../src/index');
const main = async () => {
const whatsapp = new Whatsapp();
await whatsapp.init({
mobile: 'MY MOBILE NUMBER',
proxy: {
host: '127.0.0.1',
port: 1086,
},
});
let res = null;
// get sms code
res = await whatsapp.sms();
// use sms code to register
// res = await whatsapp.register({ code: '352-002' });
// if the registration is successful, you can log in directly
//res = await whatsapp.login();
// send text message
//res = await whatsapp.sendContactTextMessage({
// jid: '34633786770',
// message: 'test hello',
//});
console.log('res', res);
};
main();