I am getting following error, when build nodejs project with webpack.
ERROR in ./node_modules/mime/mime.js
Module not found: Error: Can't resolve 'fs' in 'C:\Sample\node-ts-sample\node_modules\mime'
@ ./node_modules/mime/mime.js 2:9-22
@ ./node_modules/send/index.js
@ ./node_modules/express/lib/response.js
@ ./node_modules/express/lib/express.js
@ ./node_modules/express/index.js
@ ./src/server.ts
@ ./src/index.ts
It was a node application. Added a following node in webpack config solved my issue
target:'node',
I refereed the article at https://jlongster.com/Backend-Apps-with-Webpack--Part-I
Simply add this to your webpack config file:
const webpackConfig = {
target: 'node'
};
module.exports = webpackConfig;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With