使用 webpack 构建 Nodejs 项目时出现以下错误。
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
最佳答案
这是一个 Node 应用程序。在 webpack 配置中添加以下 Node 解决了我的问题
target:'node',
我引用了这篇文章:https://jlongster.com/Backend-Apps-with-Webpack--Part-I
关于node.js - Webpack-NodeJS-找不到模块 : Error: Can't resolve 'fs' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51946848/