Z
Z
Zodtv2019-06-04 20:43:25
JavaScript
Zodtv, 2019-06-04 20:43:25

How to fix error: $ is not defined?

I am creating an application for node, in this case:

fs.readdir('./commands/', (err, files) =>{
  if(err){console.log(err)};
  let jsfile = files.filter(f => f.split('.').pop() === 'js');
  if(jsfile.length <= '0'){console.log('could not find target')};
  files.forEach((f, i) =>{
    var props = require('./commands/${f}');
    console.log('${f} loaded!')
    bot.commands.set(props.help.name, props); /* часть discrord.js библиотеки,  
не стоит обращать внимание. */
  })
})

After starting, the console displays an error:
Error: $ is not defined
What is my mistake?
A screenshot from the editor is attached in the comments.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2019-06-04
@Zodtv

require(`./commands/${f}`);
Template strings

G
goblin3564, 2019-06-23
@goblin3564

You can use the main output option:
console.log(f+"loaded!");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question