emerysteele / minecraft-server-status-bot

Minecraft Server Status Bot for Discord
21 stars 23 forks source link

module missing #5

Closed AJANILOY closed 2 years ago

AJANILOY commented 2 years ago

whenever i try to start the bot it says `internal/modules/cjs/loader.js:1015 throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/aja/Documents/node_modules/node-fetch/src/index.js require() of ES modules is not supported. require() of /home/aja/Documents/node_modules/node-fetch/src/index.js from /home/aja/Documents/minecraft-server-status-bot-main/app.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/aja/Documents/node_modules/node-fetch/package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
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)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/aja/Documents/minecraft-server-status-bot-main/app.js:2:15)
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) {

code: 'ERR_REQUIRE_ESM' } `

emerysteele commented 2 years ago

seems there have been some changes in newer versions of the dependencies that break the app

in the meantime, I have added packages.json with the dependency versions needed CD to the app folder + run npm install to have it install the required versions (node-fetch@2.6.1,discord.js@12.3.1,ms@2.1.2)