DEV Community

Discussion on: Телеграм-бот на NodeJS. 2. Отправить музыку, фото.

Collapse
 
rekonner profile image
Rekonner

C:\Users\hilki\OneDrive\Рабочий стол\Telegramm bot JS\bot.js:2
const fetch = require("node-fetch");
^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\hilki\OneDrive\Рабочий стол\Telegramm bot JS\node_modules\node-fetch\src\index.js from C:\Users\hilki\OneDrive\Рабочий стол\Telegramm bot JS\bot.js not supported.
Instead change the require of index.js in C:\Users\hilki\OneDrive\Рабочий стол\Telegramm bot JS\bot.js to a dynamic import() which is available in all CommonJS modules.
at Object. (C:\Users\hilki\OneDrive\Рабочий стол\Telegramm bot JS\bot.js:2:15) {
code: ←[32m'ERR_REQUIRE_ESM'←[39m
}
Что делать?
Fetch подключил

Collapse
 
slkarol profile image
Stanislav Karol

С таким не встречался, но в описании написано, что вместо require сделайте import.

Collapse
 
shiradzee profile image
shiradzee

npm install node-fetch@2
у меня с этим заработало.