Module not found: Error: Can't resolve 'fs' in '/home/user/Desktop/all/editor/node_modules/winston/dist/winston'
Module not found: Error: Can't resolve 'fs' in '/home/user/Desktop/all/editor/node_modules/winston/dist/winston'
我试图将 winston logger 添加到项目中,但出现以下错误:
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
我已经尝试在 webpack 配置文件中添加 node: { fs: 'empty' }
并且还尝试了 target: 'node' 。没用。
在我的例子中,我是在浏览器环境中导入 winston,而 winston 还不支持浏览器环境。
在此处查看 shawnxusy 的评论:https://github.com/winstonjs/winston/issues/925
我试图将 winston logger 添加到项目中,但出现以下错误:
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
我已经尝试在 webpack 配置文件中添加 node: { fs: 'empty' }
并且还尝试了 target: 'node' 。没用。
在我的例子中,我是在浏览器环境中导入 winston,而 winston 还不支持浏览器环境。 在此处查看 shawnxusy 的评论:https://github.com/winstonjs/winston/issues/925