I was trying to add winston logger to the project, but getting these errors:
ERROR in ./node_modules/winston/dist/winston/tail-file.js
Module not found: Error: Can't resolve 'fs' in '/home/user/Desktop/all/editor/node_modules/winston/dist/winston'
@ ./node_modules/winston/dist/winston/tail-file.js 9:9-22
@ ./node_modules/winston/dist/winston/transports/file.js
@ ./node_modules/winston/dist/winston/transports/index.js
@ ./node_modules/winston/dist/winston.js
@ ./winston.js
@ ./client/modules/App/App.jsx
@ ./client/routes.jsx
@ ./client/index.jsx
@ multi core-js/modules/es6.promise core-js/modules/es6.array.iterator webpack-hot-middleware/client react-hot-loader/patch ./client/index.jsx
ERROR in ./node_modules/winston/dist/winston/transports/file.js
Module not found: Error: Can't resolve 'fs' in '/home/user/Desktop/all/editor/node_modules/winston/dist/winston/transports'
@ ./node_modules/winston/dist/winston/transports/file.js 33:9-22
@ ./node_modules/winston/dist/winston/transports/index.js
@ ./node_modules/winston/dist/winston.js
@ ./winston.js
@ ./client/modules/App/App.jsx
@ ./client/routes.jsx
@ ./client/index.jsx
@ multi core-js/modules/es6.promise core-js/modules/es6.array.iterator webpack-hot-middleware/client react-hot-loader/patch ./client/index.jsx
I have already tried adding node: { fs: 'empty' }
in webpack config file and also tried target: 'node' . It's not working.
In my case I was importing winston in a browser environment and winston does not support browser environment yet. Check shawnxusy's comment here: https://github.com/winstonjs/winston/issues/925