S
S
sleep2-night2021-01-25 23:02:13
Node.js
sleep2-night, 2021-01-25 23:02:13

What happened to the telegraf scenes?

I am writing a telegram bot and I needed to use scenes. Accordingly, I take the code from my old project and paste it into mine, and it displays the following error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './scenes/base' is not defined by "exports" in C:\Users\sasha\Desktop\bot\node_modules\telegraf\package.json
    at applyExports (internal/modules/cjs/loader.js:490:9)
    at resolveExports (internal/modules/cjs/loader.js:506:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:634:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:27)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\sasha\Desktop\bot\Scees.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}


I climb on the Internet, I look, but nothing is clear with the scenes. How to do them now? There is nothing sensible on the Internet about this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MagnusDidNotBetray, 2021-01-25
@MagnusDidNotBetray

//index.js

const { Telegraf, Markup, Scenes, session } = require('telegraf');
const firstScene = require('./controllers/first');
const secondScene = require('./controllers/second');

const bot = new Telegraf(token, {});
const stage = new Scenes.Stage([
   firstScene,
   secondScene
]);

bot.use(stage.middleware());

// controllers/first/index.js

const { Scenes } = require('telegraf');

const first = new Scenes.BaseScene('first');

first.enter(async ctx => {});

module.exports = first;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question