当我尝试使用webpack编译时出现这些错误:
ERROR in ./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' in '/home/maxim/test/test/node_modules/destroy'
@ ./node_modules/destroy/index.js 14:17-30
@ ./node_modules/koa/lib/response.js
@ ./node_modules/koa/lib/application.js
@ ./src/index.js
ERROR in ./node_modules/koa/lib/request.js
Module not found: Error: Can't resolve 'net' in '/home/maxim/test/test/node_modules/koa/lib'
@ ./node_modules/koa/lib/request.js 9:12-26
@ ./node_modules/koa/lib/application.js
@ ./src/index.js
这是我的webpack.config.js:
const path = require("path");
module.export = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
};
我该怎么办? 谢谢
答案 0 :(得分:0)
我认为问题是webpack试图捆绑浏览器的koajs,但这是不可能的。请参阅下面的Github问题。
https://github.com/koajs/koa/issues/1013
在webpack配置对象中指定target: "node"
应该可以解决问题。