1

I am trying to make a telegram bot using their apis and MTProto. I imported telegram-mtproto into my code and received an error:

ERROR in ./node_modules/telegram-mtproto/es/worker.js (./node_modules/worker-loader?inline!./node_modules/telegram-mtproto/es/worker.js)
Module build failed (from ./node_modules/worker-loader/index.js):
TypeError: Cannot read property 'context' of undefined
    at Object.pitch (/Volumes/Work/Work/React/Lotteo/loteo-web/node_modules/worker-loader/index.js:32:46)
 @ ./node_modules/telegram-mtproto/es/crypto.js 53:18-61
 @ ./node_modules/telegram-mtproto/es/index.js
 @ ./src/common/utils/initializers.ts
 @ ./src/common/utils/index.ts
 @ ./src/logger/rollbar.ts
 @ ./src/logger/index.ts
 @ ./src/index.tsx
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 (webpack)/hot/dev-server.js ./src

Here is my code:

const MTProto = require('telegram-mtproto').default;
const telPhone = { num : '', code: '' };
const api = { layer : '', initConnection : '', api_id : '' };
const server = { dev: true };
const client = MTProto({ server, api }); 

I'm not sure what is wrong with it after adding telegram-mtproto package?

Ari Seyhun
  • 11,506
  • 16
  • 62
  • 109
maksym
  • 21
  • 2

1 Answers1

0

I had a similar issue. I am also using the telegram-mtproto library.

The following steps worked for me:

  1. installed version 3.2.11. You can get this version via npm install -S telegram-mtproto@alpha. See more info about this release here telegram-mtproto 3.2.11 release note

  2. I Installed worker-loader as a dev dependency. npm install -D worker-loader.

This two steps cleared all the errors I had. Good luck!

theo.io
  • 1
  • 1