嗨,我正在为Webpack捆绑Node。
var path = require('path');
var nodeExternals = require('webpack-node-externals');
module.exports = {
entry: './src/main.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
externals: [nodeExternals()],
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ }
]
}
}
此代码引用了在各种环境中下游使用的几个节点模块。
构建失败并显示:
ERROR in ./src/database.js
Module not found: Error: Can't resolve 'better-sqlite3' in '/home/owner/workspace/client/node-server/src'
@ ./src/database.js 10:43-68
@ ./src/main.js
ERROR in ./src/ffmpeg.js
Module not found: Error: Can't resolve 'fluent-ffmpeg' in '/home/owner/workspace/client/node-server/src'
@ ./src/ffmpeg.js 10:43-67
@ ./src/server.js
@ ./src/main.js
ERROR in ./src/master.js
Module not found: Error: Can't resolve 'local-devices' in '/home/owner/workspace/client/node-server/src'
@ ./src/master.js 8:43-67
@ ./src/server.js
@ ./src/main.js
ERROR in ./src/master.js
Module not found: Error: Can't resolve 'qrcode' in '/home/owner/workspace/client/node-server/src'
@ ./src/master.js 10:37-54
@ ./src/server.js
@ ./src/main.js
如何让Webpack忽略这些而让我进行构建?