{"id":12071,"library":"start-server-webpack-plugin","title":"Start Server Webpack Plugin","description":"start-server-webpack-plugin is a Webpack plugin designed to automatically launch a Node.js server process once Webpack's build completes, primarily for development environments. It allows developers to integrate server-side applications, such as Express, directly into their Webpack development workflow. The plugin supports features like Hot Module Replacement (HMR) for server-side code, debugging via Node.js arguments, and automatic server restarts on file changes. The current stable version is 2.2.5, however, the package has not been updated since March 2018, indicating it is no longer actively maintained. Newer Webpack versions (like Webpack 5) are not officially supported, leading users to seek alternatives or forks for compatibility. Key differentiators include its focused role in *starting* a server post-build, rather than providing a full development server like webpack-dev-server, and its ability to pass arguments directly to the Node.js process and the target script itself.","status":"abandoned","version":"2.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/ericclemmons/start-server-webpack-plugin","tags":["javascript","webpack","server","start","watch","restart","express"],"install":[{"cmd":"npm install start-server-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add start-server-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add start-server-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency as a Webpack plugin. Requires Webpack 4 or earlier for full compatibility.","package":"webpack","optional":false}],"imports":[{"note":"While primarily used with ESM imports in modern JavaScript projects, CJS `require` syntax was also common. Ensure your Webpack configuration's module system aligns with your chosen import style.","wrong":"const StartServerPlugin = require('start-server-webpack-plugin');","symbol":"StartServerPlugin","correct":"import StartServerPlugin from 'start-server-webpack-plugin';"},{"note":"For older Webpack configurations or CommonJS-based projects, `require` syntax is applicable. Note that this package itself uses ESM in its README examples but provides CJS compatibility.","symbol":"StartServerPlugin (CommonJS)","correct":"const StartServerPlugin = require('start-server-webpack-plugin');"}],"quickstart":{"code":"const path = require('path');\nconst webpack = require('webpack');\nconst StartServerPlugin = require('start-server-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  target: 'node',\n  entry: {\n    server: [\n      'webpack/hot/poll?1000',\n      path.resolve(__dirname, 'src', 'server.js'),\n    ],\n  },\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: '[name].js',\n  },\n  watch: true,\n  externals: [\n    // In order to ignore all modules in node_modules folder from bundling\n    /^[a-z\\-0-9]+$/,\n  ],\n  plugins: [\n    // Only use this in DEVELOPMENT\n    new StartServerPlugin({\n      name: 'server.js', // Must match the output filename for the server entry\n      nodeArgs: ['--inspect'], // Allows attaching a Node.js debugger\n      args: ['--dev-mode'], // Pass custom arguments to your server script\n      signal: true, // Send SIGUSR2 to restart the server for HMR\n      keyboard: true, // Allow 'rs' to restart from terminal\n    }),\n    new webpack.HotModuleReplacementPlugin(),\n    new webpack.NoEmitOnErrorsPlugin(), // Good practice for HMR\n  ],\n};\n\n// src/server.js (example)\n// const express = require('express');\n// const app = express();\n// const port = process.env.PORT || 3000;\n\n// app.get('/', (req, res) => {\n//   res.send('Hello from server! Updated: ' + new Date().toLocaleTimeString());\n// });\n\n// app.listen(port, () => {\n//   console.log(`Server listening on port ${port}`);\n// });\n\n// if (module.hot) {\n//   module.hot.accept();\n//   module.hot.dispose(() => console.log('Server disposing...'));\n// }","lang":"javascript","description":"This quickstart demonstrates a typical Webpack configuration using `start-server-webpack-plugin` to compile and launch a Node.js server. It includes basic Hot Module Replacement (HMR) setup, debugging flags, and an example server structure."},"warnings":[{"fix":"Consider migrating to alternatives like `webpack-dev-server` with `webpack-node-externals` or a custom Node.js script that watches Webpack output. A community-maintained fork like `start-server-nestjs-webpack-plugin` might offer Webpack 5 compatibility.","message":"This package has not been updated since March 2018 and does not officially support Webpack 5 or later. Using it with modern Webpack versions will likely result in compatibility issues or require significant manual patching.","severity":"breaking","affected_versions":">=3.0.0 (Webpack versions)"},{"fix":"Add `webpack/hot/poll?1000` to your server's Webpack `entry` array. If using `webpack-node-externals`, ensure its `whitelist` option includes `['webpack/hot/poll?1000', 'webpack/hot/signal']`.","message":"When using Hot Module Replacement (HMR) with this plugin, you must include `webpack/hot/poll?1000` (or `webpack/hot/signal`) as an entry point for your server bundle. Additionally, if using `webpack-node-externals`, ensure these HMR modules are whitelisted so they are bundled, not excluded.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Ensure `new StartServerPlugin({ name: 'your-server-bundle.js' })` matches your `output.filename` (e.g., `server.js`). If no name is provided, the plugin attempts to infer but it's best to specify it explicitly.","message":"The `name` option in `StartServerPlugin` is crucial, especially for multi-entrypoint Webpack configurations. It must exactly match the `filename` of the server bundle output in your Webpack configuration. Omitting or misconfiguring it can lead to the plugin not knowing which asset to start.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Wrap the plugin instantiation in an environment check: `process.env.NODE_ENV === 'development' ? new StartServerPlugin(...) : null`. Alternatively, use separate Webpack configurations for development and production.","message":"This plugin is explicitly intended for development environments. Its functionality for starting and restarting processes is not suitable for production deployments and should be disabled or removed in production builds.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Add the `name` option to `StartServerPlugin` constructor, ensuring it matches the exact filename of your server bundle. E.g., `new StartServerPlugin({ name: 'server.js' })` if your output filename is `server.js`.","cause":"The `name` option was not provided or does not match the output filename for the server entry.","error":"Error: Plugin names missing: <some-filename-or-path>. This way, the plugin knows which entry to start in case there are several."},{"fix":"This specific plugin is old. Upgrade `webpack` and `webpack-cli` to compatible versions, or consider switching to a modern development server setup that inherently supports newer Webpack versions, such as `webpack-dev-server` (standalone) or alternatives.","cause":"This error often indicates incompatibility between `webpack-dev-server` or related plugins and newer versions of `webpack-cli` or `webpack` itself. It suggests the underlying `webpack-dev-server` (or similar) is having trouble locating its internal modules, typically due to outdated dependencies.","error":"Cannot find module 'webpack/bin/config-yargs'"}],"ecosystem":"npm"}