在尝试使用webpack的第一步时,我偶然发现了这个错误.
只是为了在一个非常基础的层面上重现效果,我设置了这样的微文件夹,如下所示:
节点试验-2
具有以下内容:
的package.json
{
"name": "node-test-2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack && node bundle.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^2.2.0"
}
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js
var path = require('path');
module.exports = {
entry : './main.js',
output : {
path : path.resolve(__dirname),
filename : 'bundle.js'
}
}
Run Code Online (Sandbox Code Playgroud)
main.js
var http = require('http');
console.log("Creating Server");
var server = http.createServer(function(req, res){
console.log('Connection Estabilished!');
res.write('HELLO!');
res.end();
});
console.log("Listening on port " …Run Code Online (Sandbox Code Playgroud)