Webpack's require.context
is a powerful feature which helps to extract an array of paths within which the search of modules will be done. e.g.:
const requireFromContext = require.context(__dirname, true, /config\.js$/);
// Now `requireFromContext` contains files inside `__dirname/config` folder and which extension is `.js`
require.context
is a special feature of webpack. Native nodejs's require
doesn't containt that method and if you want to run unbundled code on nodejs, then you have to emulate require.context
.