Vue3+Winston3+Webpack5项目中无法解析'fs'模块求助
Winston@3 编译报错:无法解析 'fs' 模块
我在项目里用Winston@3做日志工具,编译的时候一直出问题,提示找不到'fs'模块,错误信息如下:
Compiled with problems: ERROR in ./node_modules/winston/dist/winston/tail-file.js 12:9-22 Module not found: Error: Can't resolve 'fs' in '/app/node_modules/winston/dist/winston' ERROR in ./node_modules/winston/dist/winston/transports/file.js 136:9-22 Module not found: Error: Can't resolve 'fs' in '/app/node_modules/winston/dist/winston/transports'
错误截图:
我试了好几种办法都没解决:
- 在
package.json里定义了browser字段,限制Node.js模块的使用 - 在
webpack.config.js里配置resolve.fallback: { fs: 'empty' } - 在
vue.config.js的webpack配置里给fs设置别名 - 检查过TypeScript配置,应该不是TS的问题
有没有人遇到过类似情况?求可行的解决办法,谢谢!
内容的提问来源于stack exchange,提问作者JanakDom
相关产品推荐
相关产品推荐

