MODULE_NOT_FOUND: telegraf
Laiteux opened this issue · comments
Hello,
I've been using a self-hosted DiscussUnpinBot for the last few months, and today tried upgrading to the last update, with support for the bot API 5.0.
I cloned the repo, however after running npm install
and trying to use npm start
, this is the error I am getting:
root@matt:~/telegram-bots/DiscussUnpinBot# npm start
> discussunpinbot@1.0.0 start /root/telegram-bots/DiscussUnpinBot
> node index.js
internal/modules/cjs/loader.js:438
throw e;
^
Error: Cannot find module '/root/telegram-bots/DiscussUnpinBot/node_modules/telegraf/lib/index.js'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:907:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:900:15)
at resolveExports (internal/modules/cjs/loader.js:432:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/root/telegram-bots/DiscussUnpinBot/index.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30) {
code: 'MODULE_NOT_FOUND',
path: '/root/telegram-bots/DiscussUnpinBot/node_modules/telegraf/package.json'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discussunpinbot@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discussunpinbot@1.0.0 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! /root/.npm/_logs/2020-11-26T04_18_55_375Z-debug.log
I tried resolving it by myself, but couldn't. I noticed the index.js
file npm is trying to load doesn't exist. In fact, the telegraf/lib
folder doesn't even exist:
root@matt:~/telegram-bots/DiscussUnpinBot# ls node_modules/telegraf/
LICENSE bin node_modules package.json readme.md
What can I do to fix this issue?
Do you have the output from npm install
?
root@matt:~/telegram-bots/DiscussUnpinBot# npm install
npm WARN discussunpinbot@1.0.0 No repository field.
added 117 packages from 70 contributors and audited 117 packages in 24.808s
9 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
I don't really know how to fix this, but I guess it doesn't hurt to try npm ci
Using npm ci
instead of npm install
actually fixed the issue. Thanks a lot for the quick help!
Cool!
Dear @AndrewLaneX
The same problem happened to me with node --version v14.15.3 npm --version 6.14.9
Update to node v15.5.0
fixes the problem. Don't know why though.
But how this bot work? I add my bot as admin in my channel and linked group. I post a message in my channel it gets forwarded to the linked group and gets pined. The bot seems doesn't do anything.
I type /help
to the bot, the bot replies: "Hi I'm a bot to unpin messages in your group when you post on the connected channel". So the bot actually up and working.
Environment
- Debian 10, node v15.5.0, npm v7.3.0
- Android Plus Messager
@ElvisXJ what permissions did you give the bot in the group?
@ElvisXJ can you try running the bot with DEBUG="telegraf:*" node index.js
?
@ElvisXJ can you try running the bot with
DEBUG="telegraf:*" node index.js
?
DEBUG info seems to show that the bot works normally, but still, the message isn't get unpinned in the group.
Process Routine
- Start the bot
- idle
- send
/help
to bot - idle
- send testing message to the channel
@ElvisXJ that's weird. Did you make any changes to the code?
@ElvisXJ that's weird. Did you make any changes to the code?
No, no modify at all. Directly deployed according to ReadMe. Maybe a more elaborate tutorial?
FYI: Just test it with your demo bot, it works flawlessly. So, now, I literally have no clue what might cause the problem.
Maybe you can check your bot log to see the difference and I will try to purge the Nodejs and redeploy the bot again.
Anyway, thanks for the help and great project. Being trying to find this kinda bot for so long.
Hate telegram always automatically pined the message that I don't want.
@AndrewLaneX Update, Just redeployed.
Nodejs LTS version v14.15.3 still shows the error message as the issue opener mentioned. But Nodejs v15.5.0 works after redeployment. So I guess maybe some strange errors or settings that cause the previous deployment didn't work.
Anyway, thanks for the great project.
@ElvisXJ have you tried npm ci
with node v14?
@ElvisXJ have you tried
npm ci
with node v14?
Yes, with LTS version, tried both npm install
and npm ci
But end with the same error.
Using the latest nodejs version solves the problem as mentioned above.
This is very strange. Do you mind joining https://t.me/TwitFaceChat to further discuss this?