Use childprocess.fork() instead of cluster
See original GitHub issueI am getting title error after adding webpack-hot-middleware
and webpack-dev-middleware
to the server as shown here: https://github.com/gaearon/react-hot-boilerplate/blob/master/server.js
Listening at http://localhost:8080
/Users/montogeek/project/node_modules/start-server-webpack-plugin/dist/StartServerPlugin.js:64
_cluster2.default.setupMaster({ exec: existsAt });
^
TypeError: _cluster2.default.setupMaster is not a function
at StartServerPlugin.startServer (/Users/montogeek/project/node_modules/start-server-webpack-plugin/dist/StartServerPlugin.js:64:25)
at StartServerPlugin.afterEmit (/Users/montogeek/project/node_modules/start-server-webpack-plugin/dist/StartServerPlugin.js:36:12)
at Compiler.applyPluginsAsyncSeries1 (/Users/montogeek/project/node_modules/tapable/lib/Tapable.js:158:13)
at Compiler.afterEmit (/Users/montogeek/project/node_modules/webpack/lib/Compiler.js:352:8)
at Compiler.<anonymous> (/Users/montogeek/project/node_modules/webpack/lib/Compiler.js:347:14)
at /Users/montogeek/project/node_modules/async/dist/async.js:360:16
at iteratorCallback (/Users/montogeek/project/node_modules/async/dist/async.js:936:13)
at /Users/montogeek/project/node_modules/async/dist/async.js:844:16
at MemoryFileSystem.writeFile (/Users/montogeek/project/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9)
at Compiler.writeOut (/Users/montogeek/project/node_modules/webpack/lib/Compiler.js:341:27)
webpack config:
{
entry: ["webpack/hot/poll?1000", "babel-polyfill", "./server/index"],
watch: true,
target: "node",
externals: [nodeExternals({ whitelist: ["webpack/hot/poll?1000"] })],
module: {
rules: [
{ test: /\.js?$/, use: "babel-loader", exclude: /node_modules/ },
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.svg$/,
use: "raw-loader"
},
{
test: /\.(png|jpg|gif|eot|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 10000
}
}
]
},
plugins: [
new ExtractTextPlugin("styles.css"),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new StartServerPlugin("server.js")
],
output: {
path: path.join(__dirname, ".build"),
filename: "server.js",
publicPath: "/"
}
};
Before adding that code, it worked. Maybe a compatibility issue?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
What's the difference with childprocess.fork between cluster.fork
The difference between cluster.fork() and child_process.fork() is simply that cluster allows TCP servers to be shared between workers.
Read more >Take Advantage of Node.js Cluster and Child Processes with ...
Worker processes are spawned by using the fork() method. These processes can communicate with the parent (child to parent and parent to child) ......
Read more >Single thread vs child process vs worker threads vs cluster in ...
child_process.fork() is specifically used to spawn new nodejs processes. Like spawn, the returned childProcess object will have built-in IPC ...
Read more >Node.js Child Processes: Everything you need to know
There are four different ways to create a child process in Node: spawn() , fork() , exec() , and execFile() .
Read more >Node.js cluster forking and using the 5th channel! - LinkedIn
Cluster and fork will both do the same thing. Cluster basically makes forking a bit easier. The idea here is to move your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be fixed in
start-server-webpack-plugin@beta
I think using
cluster
in the plugin is actually not a great idea, just forking and restarting would be better. So this issue is about changing the call to cluster to a call to fork.