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 подключил
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 подключил
С таким не встречался, но в описании написано, что вместо require сделайте import.
npm install node-fetch@2
у меня с этим заработало.