How to pass variable in require

Asked

Viewed 104 times

0

I am trying to pass a variable populated by the database, containing my route to require, but is giving the following error:

"Cannot find module 'views/Cadastros/Usuario'"

And these are the ways I tried to import and which unfortunately did not work

var component = require("" + listRouters[i].import).default 

var component = await (await import(listRouters[i].import).default;

var component = import(listRouters[i].import)
  • Include more code details so the problem can be evaluated.

  • Which is the path of the module you want to add?

  • the path is this 'views/Entries/User'

  • within listRouters[i]. import have 'views/Registrations/User', normal import works well.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.