Reputation: 168
I want to implement a async require so i am using a variable inside require keyword that is not working, But if i supply string it works as usual. I want a help to set it working properly
const asyncRequire = (path) => {
try {
return require(path);
} catch (error) {
LogUtils.error('Dynamic Require failed', error);
return null;
}
};
This require(path)
is not working.
Upvotes: 2
Views: 399
Reputation: 2020
You cannot use dynamic paths in require
currently. Please check this answer.
Check this issue also for discussions and possible alternatives.
Upvotes: 2