Answer the question
In order to leave comments, you need to log in
I am writing a bot in JavaScript with Node Js, when an interval is executed, an error pops up, what should I do?
When executing the node main.js command, an error occurs in the cmder.
λ node main.js
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module 'node-telegram-bot-api'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader .js:520:25)
at Module.require(internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (D:\Programming\Web\delete-me.ko\telegram bot\main.js:1:81)
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)
var TelegramBot = require('node-telegram-bot-api');
var CronJob = require('cron').CronJob;
var token = 'здесь токен';
var bot = new TelegramBot(token, {
polling: true,
});
var job = new CronJob('* * * * * *', function(){ // interval
console.log('Hey!');
});
job.start();
bot.on('message', function (msg) { //the bot polls all for the message
var id = msg.from.id;
bot.sendMessage(id, msg.text); //send's your message back
//console.log(msg);
})
Answer the question
In order to leave comments, you need to log in
npm install node-telegram-bot-api
Next time try to read the error text before going to the Toaster.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question