Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module './rpcbaseerrors' #50

Closed
tsathis opened this issue Feb 9, 2021 · 6 comments
Closed

Error: Cannot find module './rpcbaseerrors' #50

tsathis opened this issue Feb 9, 2021 · 6 comments

Comments

@tsathis
Copy link

tsathis commented Feb 9, 2021

I was going to get started with gramjs and tried by installing gramsjs with npm for a simple nodejs project.

const { TelegramClient } = require('telegram/gramjs');
const { StringSession } = require('telegram/gramjs/sessions');

const api_id = xxxxxxx;
const api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
const string_session = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...';

export function test(input: any) {
    console.log("Running test", input);
    (async () => {
        console.log('Loading interactive example...')
        const sessionName = 'anon'
        const apiId = api_id  
        const apiHash = api_hash  
        const client = new TelegramClient(new StringSession(string_session), apiId, apiHash)
        await client.connect()
        console.log('You should now be connected.')
        await client.sendMessage('me', "hi");
    })()
}

And I get the following terminal output when running it.

Error: Cannot find module './rpcbaseerrors'
Require stack:
- /home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/errors/RPCErrorList.js
- /home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/errors/index.js
- /home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/client/TelegramClient.js
- /home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/index.js
- /home/tharindu/playground/gramjs-test/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/errors/RPCErrorList.js:1:144)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/errors/RPCErrorList.js',
    '/home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/errors/index.js',
    '/home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/client/TelegramClient.js',
    '/home/tharindu/playground/gramjs-test/node_modules/telegram/gramjs/index.js',
    '/home/tharindu/playground/gramjs-test/index.js'
  ]
}

Package.json,

{
  ...
  "dependencies": {
    "telegram": "^1.0.0-alpha.2"
  }
}
@painor
Copy link
Member

painor commented Feb 9, 2021

what version of node are you using

@tsathis
Copy link
Author

tsathis commented Feb 9, 2021

$ node --version
v12.20.0

@painor
Copy link
Member

painor commented Feb 9, 2021

hmm it appears the npm version wasn't updated. you could try downloading the master version while I'm publishing it to npm

@tsathis
Copy link
Author

tsathis commented Feb 9, 2021

Ok I will try it. Thank you very much for the quick replies.

@painor
Copy link
Member

painor commented Feb 13, 2021

the npm package has been updated. feel free to try

@tsathis
Copy link
Author

tsathis commented Feb 14, 2021

Yeah its working! Thank you.

@tsathis tsathis closed this as completed Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants