im working on a telegram bot using the telegraf
package. (version 4.1.1)
everything was working until i started using more modules from the telegraf package like Extra
and mark-up
.
I started getting this error:
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'typegram/callback'
Require stack:
- C:gitprojectsbotnode_modulestelegraflibtelegram-types.js
- C:gitprojectsbotnode_modulestelegraflibcontext.js
- C:gitprojectsbotnode_modulestelegraflibcomposer.js
- C:gitprojectsbotnode_modulestelegraflibtelegraf.js
- C:gitprojectsbotnode_modulestelegraflibindex.js
- C:gitprojectsbotindex.js
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:852:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:74:18)←[39m
at Object.<anonymous> (C:gitprojectsbotnode_modules←[4mtelegraf←[24mlibtelegram-types.js:16:14)
←[90m at Module._compile (internal/modules/cjs/loader.js:959:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:815:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:727:14)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:852:19)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\gitprojects\bot\node_modules\telegraf\lib\telegram-types.js'←[39m,
←[32m'C:\gitprojects\bot\node_modules\telegraf\lib\context.js'←[39m,
←[32m'C:\gitprojects\bot\node_modules\telegraf\lib\composer.js'←[39m,
←[32m'C:\gitprojects\bot\node_modules\telegraf\lib\telegraf.js'←[39m,
←[32m'C:\gitprojects\bot\node_modules\telegraf\lib\index.js'←[39m,
←[32m'C:\gitprojects\bot\index.js'←[39m
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
‘typegram/callback’ is installed but is a typescript file,i don’t have typescript installed but i didn’t have issues before the error.
I reverted to my latest working build but the error hasn’t changed..
right now this is the only line of code:
const { Telegraf } = require('telegraf');
Any tips?
3
Answers
Well... in case anyone ever gets this error here is how i solved it.
after avoiding this issue by crying, sleeping and watching stupid youtube videos (shout out to Sseth).
ive reinstalled everything i could, nothing helped. checked npm version and noticed my code appeared as a installed package, i thought "Die" and removed it. for some reason that fixed it. if anyone knows the reason behind this behavior i would love to know.
you're all great, have a good one.
Solved by downgrading to 4.1.0 version of the package.
Telegraf 1.4.x requires Node 12.x.x ++
Upgrade to the latest Node LTS (14) – you should be ok.