0
votes

    ERROR in ./node_modules/mime/mime.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\mime'
     @ ./node_modules/mime/mime.js 2:9-22
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/node-telegram-bot-api/lib/telegramWebHook.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\node-telegram-bot-api\lib'
     @ ./node_modules/node-telegram-bot-api/lib/telegramWebHook.js 11:9-22
     @ ./node_modules/node-telegram-bot-api/lib/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/node-telegram-bot-api/lib/telegram.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\node-telegram-bot-api\lib'
     @ ./node_modules/node-telegram-bot-api/lib/telegram.js 31:9-22
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/node-telegram-bot-api/src/telegram.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\node-telegram-bot-api\src'
     @ ./node_modules/node-telegram-bot-api/src/telegram.js 17:11-24
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/node-telegram-bot-api/src/telegramWebHook.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\node-telegram-bot-api\src'
     @ ./node_modules/node-telegram-bot-api/src/telegramWebHook.js 5:11-24
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/request/lib/har.js
    Module not found: Error: Can't resolve 'fs' in 'my-project\node_modules\request\lib'
     @ ./node_modules/request/lib/har.js 3:9-22
     @ ./node_modules/request/request.js
     @ ./node_modules/request/index.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/forever-agent/index.js
    Module not found: Error: Can't resolve 'net' in 'my-project\node_modules\forever-agent'
     @ ./node_modules/forever-agent/index.js 6:10-24
     @ ./node_modules/request/request.js
     @ ./node_modules/request/index.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/tough-cookie/lib/cookie.js
    Module not found: Error: Can't resolve 'net' in 'my-project\node_modules\tough-cookie\lib'
     @ ./node_modules/tough-cookie/lib/cookie.js 32:10-24
     @ ./node_modules/request-promise/lib/rp.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'net' in 'my-project\node_modules\tunnel-agent'
     @ ./node_modules/tunnel-agent/index.js 3:10-24
     @ ./node_modules/request/lib/tunnel.js
     @ ./node_modules/request/request.js
     @ ./node_modules/request/index.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/forever-agent/index.js
    Module not found: Error: Can't resolve 'tls' in 'my-project\node_modules\forever-agent'
     @ ./node_modules/forever-agent/index.js 7:10-24
     @ ./node_modules/request/request.js
     @ ./node_modules/request/index.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js

    ERROR in ./node_modules/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'tls' in 'my-project\node_modules\tunnel-agent'
     @ ./node_modules/tunnel-agent/index.js 4:10-24
     @ ./node_modules/request/lib/tunnel.js
     @ ./node_modules/request/request.js
     @ ./node_modules/request/index.js
     @ ./node_modules/node-telegram-bot-api/src/telegram.js
     @ ./node_modules/node-telegram-bot-api/index.js
     @ ./client/index.js
    
<pre>
import React, { Component } from "react";
import { render } from "react-dom";
import Home from "./components/Home.jsx";

const TelegramBot = require('node-telegram-bot-api');
const token = "MY_TOKEN";
const bot = new TelegramBot(token, {polling: true});

render(Home, document.getElementById("root"));

1

1 Answers

0
votes

You can't use require in a browser application (like react). require is for node.js apps, only do import.

This telegram bot seems to require access to the filesystem (fs) and that is not available in the browser anyway, so you won't be able to use it directly in the frontend.

Sorry for the bad news.