require.extensions is not supported by webpack. Use a loader instead require.extensions is not supported by webpack. Use a loader instead node.js node.js

require.extensions is not supported by webpack. Use a loader instead


The best solution for this is using webpack-node-externals to not worry about node_modules at all when working with webpack for backend.

When bundling with Webpack for the backend - you usually don't want to bundle its node_modules dependencies. This library creates an externals function that ignores node_modules when bundling in Webpack.


I had the same problem and I solved it by adding the following code to my webpack.config.js file:

resolve: {   alias: {       'express-handlebars': 'handlebars/dist/handlebars.js'   }}


This set up uses ejs and the ejs-specific solution is to set this in your webpack config:

resolve: {   alias: {     'ejs': 'ejs.min.js'   }}