I get some confusing warnings when creating a Node backend server using Webpack. I want to use Webpack to create my backend primarily for two reasons:
- Webpack creates one executable file that is easier to deploy
- Webpack includes all my application dependencies, so I can deploy my application to any compatible Node environment without having to install dependencies first
Here are the warnings I get:
WARNING in ./~/ws/lib/BufferUtil.js
Module not found: Error: Can't resolve 'bufferutil' in .../node_modules/ws/lib
@ ./~/ws/lib/BufferUtil.js 35:21-42
@ ./~/ws/lib/Receiver.js
@ ./~/ws/index.js
@ ./src/main.js
WARNING in ./~/ws/lib/Validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in .../node_modules/ws/lib
@ ./~/ws/lib/Validation.js 10:22-47
@ ./~/ws/lib/Receiver.js
@ ./~/ws/index.js
@ ./src/main.js
WARNING in ./~/express/lib/view.js
80:29-41 Critical dependency: the request of a dependency is an expression
Critical dependency , , , ContextReplacementPlugin, , . , 80 node_modules/express/lib/view.js:
opts.engines[this.ext] = require(mod).__express
, , ContextReplacementPlugin ?
Module not found ws, , . , node_modules, , , Webpack. devDependencies, Critical dependency .
- , , , , , Node, Webpack - , .
package.json:
"devDependencies": {
"@types/cassandra-driver": "^0.8.10",
"@types/express": "^4.0.35",
"@types/uuid": "^2.0.29",
"@types/ws": "0.0.40",
"nodemon": "^1.11.0",
"typescript": "^2.3.1",
"webpack": "^2.5.1"
},
"dependencies": {
"cassandra-driver": "^3.2.1",
"express": "^4.15.2",
"uuid": "^3.0.1",
"ws": "^2.3.1"
}
webpack.config.js:
const path = require('path');
module.exports = {
entry: './src/main.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'main.js'
},
target: 'node',
node: {
__dirname: false,
__filename: false
}
};
, . .