N
N
No2020-06-01 19:58:47
JavaScript
No, 2020-06-01 19:58:47

How to specify a relative path to a file?

Good evening, I'm trying to specify the relative path of the project. I have two folders. In the handlers folder I have a handler.js file with the following code:

const commandFiles = fs.readdirSync(`../commands/`).filter(file => file.endsWith('.js')); 

        for (const file of commandFiles) {
            const command = require(`../commands/${file}`); 
        
            client.commands.set(command.name, command);
        }


And the second folder commands. To which I am trying to specify a relative path.
This code does not work, it gives an error that the file or directory was not found. Tell me how can this be done?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question