Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

370
Vistas
Replacing main.js with index.js, Error: ENOENT?

I'm confused with why is this bot now functioning, I think it's as I don't have a "index.js" I use "main.js" How can I some how switch from "main.js" to "index.js"?

I'll add all the main codes that may help you spot an error :D

Here is the code in "main.js":

const { Client, Collection, Intents } = require('discord.js');
const client = new Client({ disableMentions: 'everyone', partials: 
['MESSAGE', 'CHANNEL', 'REACTION'], ws: { intents: Intents.ALL } });


client.commands = new Collection();
client.aliases = new Collection();

['command', 'event'].forEach(handler => {
    require(`./handlers/${handler}`)(client);
});


client.login(process.env.BOT_TOKEN);

Error:

internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/runner/DwaCraft-Ticket-bot/index.js'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (/run_dir/interp.js:195:19)
    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)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/runner/DwaCraft-Ticket-bot/index.js'
}
repl process died unexpectedly: exit status 1
 

Package.json:

{
    "name": "ticket-bot",
    "version": "1.0.0",
    "description": "A simple ticket bot",
    "main": "main.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node main.js"
    },
    "author": "hamoodi",
    "license": "ISC",
    "dependencies": {
        "better": "^0.1.0",
        "cpu-stat": "^2.0.1",
        "discord.js": "^12.5.3",
        "dotenv": "^8.6.0",
        "express": "^4.17.1",
        "moment": "^2.29.1",
        "os": "^0.1.2",
        "sourcebin_js": "0.0.3-ignore"
    }
}

Files:

https://i.stack.imgur.com/FptiD.png

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As below link said you can Create a .replit file, and inside it put

run="node [file].js"

and replace [file] to main.

https://replit.com/talk/ask/Is-it-possible-to-changedeleted-indexjs/43264

about 4 years ago · Juan Pablo Isaza Denunciar

0

Change the name file from main.js to index.js in "scripts" => "start" in package.json file and hit npm start. Remember to run the script from the folder where the main.js file is located, and rename files!

{
    "name": "ticket-bot",
    "version": "1.0.0",
    "description": "A simple ticket bot",
    "main": "main.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "node index.js"
    },
    "author": "hamoodi",
    "license": "ISC",
    "dependencies": {
        "better": "^0.1.0",
        "cpu-stat": "^2.0.1",
        "discord.js": "^12.5.3",
        "dotenv": "^8.6.0",
        "express": "^4.17.1",
        "moment": "^2.29.1",
        "os": "^0.1.2",
        "sourcebin_js": "0.0.3-ignore"
    }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda