SpaghettDev / Economy-Bot

A discord.js economy bot.
MIT License
58 stars 60 forks source link

Getting Error when I "npm start" #15

Open sam0oo7 opened 3 years ago

sam0oo7 commented 3 years ago

C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main\handlers\economybot.js:12 this.commands = new Discord.Collection(); ^

ReferenceError: Discord is not defined at new economybot (C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main\handlers\economybot.js:12:22) at Object. (C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main\index.js:8:18) at Module._compile (internal/modules/cjs/loader.js:1072:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) at Module.load (internal/modules/cjs/loader.js:937:32) at Function.Module._load (internal/modules/cjs/loader.js:778:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! Discord.js-Economy-Bot@1.7.1 start: node index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the Discord.js-Economy-Bot@1.7.1 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sambo\AppData\Roaming\npm-cache_logs\2021-08-17T21_29_19_717Z-debug.log

Elijah2101021 commented 3 years ago

Same error

Sauravlol commented 3 years ago

try npm install discord.js

norbsdev commented 3 years ago

add a const Discord = require('discord.js') at the top of your file @sam0oo7

BUBUSTEIN13 commented 3 years ago

image

norbsdev commented 3 years ago

show the whole error

BUBUSTEIN13 commented 3 years ago

image

BUBUSTEIN13 commented 3 years ago

i added const Discord = require("discord.js") on the top and this is the new error

npm start

Discord.js-Economy-Bot@1.7.1 start /home/runner/Economy-Bot node index.js

[Event-loading-logs] Loading 6 Client Events! [Event-loading-logs] Successfully Loaded Client Event : disconnect.js [Event-loading-logs] Successfully Loaded Client Event : error.js [Event-loading-logs] Successfully Loaded Client Event : message.js [Event-loading-logs] Successfully Loaded Client Event : ready.js [Event-loading-logs] Successfully Loaded Client Event : reconnecting.js [Event-loading-logs] Successfully Loaded Client Event : warn.js

[Directory-loading-logs] Loading 17 commands of module Economy :

[Command-loading-logs] Loaded command : balance.js 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/runner/Economy-Bot/node_modules/parse-ms/index.js require() of ES modules is not supported. require() of /home/runner/Economy-Bot/node_modules/parse-ms/index.js from /home/runner/Economy-Bot/Commands/Economy/beg.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/runner/Economy-Bot/node_modules/parse-ms/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/runner/Economy-Bot/Commands/Economy/beg.js:2:12)
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' } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! Discord.js-Economy-Bot@1.7.1 start: node index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the Discord.js-Economy-Bot@1.7.1 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/runner/.npm/_logs/2021-10-10T11_21_03_783Z-debug.log exit status 1

norbsdev commented 3 years ago

do npm i parse-ms@2.1.0

norbsdev commented 3 years ago

in your shell or terminal

norbsdev commented 3 years ago

@BUBUSTEIN13

BUBUSTEIN13 commented 3 years ago

Thanks finally the bot is online

sam0oo7 commented 3 years ago

@BUBUSTEIN13 How did you fix it cus i still cant figure out the way

sam0oo7 commented 3 years ago

0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'start' 1 verbose cli ] 2 info using npm@6.14.15 3 info using node@v14.18.1 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle Discord.js-Economy-Bot@1.7.1~prestart: Discord.js-Economy-Bot@1.7.1 6 info lifecycle Discord.js-Economy-Bot@1.7.1~start: Discord.js-Economy-Bot@1.7.1 7 verbose lifecycle Discord.js-Economy-Bot@1.7.1~start: unsafe-perm in lifecycle true 8 verbose lifecycle Discord.js-Economy-Bot@1.7.1~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main\node_modules.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\sambo\AppData\Local\Microsoft\WindowsApps;C:\Users\sambo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sambo\AppData\Roaming\npm 9 verbose lifecycle Discord.js-Economy-Bot@1.7.1~start: CWD: C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main 10 silly lifecycle Discord.js-Economy-Bot@1.7.1~start: Args: [ '/d /s /c', 'node index.js' ] 11 silly lifecycle Discord.js-Economy-Bot@1.7.1~start: Returned: code: 1 signal: null 12 info lifecycle Discord.js-Economy-Bot@1.7.1~start: Failed to exec start script 13 verbose stack Error: Discord.js-Economy-Bot@1.7.1 start: node index.js 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:400:28) 13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:400:28) 13 verbose stack at maybeClose (internal/child_process.js:1058:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) 14 verbose pkgid Discord.js-Economy-Bot@1.7.1 15 verbose cwd C:\Users\sambo\OneDrive\Desktop\Economy-Bot-main 16 verbose Windows_NT 10.0.19042 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" 18 verbose node v14.18.1 19 verbose npm v6.14.15 20 error code ELIFECYCLE 21 error errno 1 22 error Discord.js-Economy-Bot@1.7.1 start: node index.js 22 error Exit status 1 23 error Failed at the Discord.js-Economy-Bot@1.7.1 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]