{"id":20531,"library":"run-node-webpack-plugin","title":"RunNodeWebpackPlugin","description":"Webpack plugin that automatically starts and restarts a Node.js script after webpack compilation. Version 2.0.0 requires webpack ^5.0.0 and ships TypeScript types. Key differentiators: runs scripts only on actual bundle changes (not every recompilation), supports custom script selection, watch-mode control, and process argument configuration. More efficient than nodemon/pm2 for webpack dev workflows. Actively maintained on GitHub.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/rdoo/run-node-webpack-plugin","tags":["javascript","run","start","restart","node","nodejs","script","server","webpack","typescript"],"install":[{"cmd":"npm install run-node-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add run-node-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add run-node-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin is designed as a webpack plugin and requires webpack 5+","package":"webpack","optional":false}],"imports":[{"note":"Default export; must use default import. Named import or destructured require will fail.","wrong":"const { RunNodeWebpackPlugin } = require('run-node-webpack-plugin')","symbol":"RunNodeWebpackPlugin","correct":"import RunNodeWebpackPlugin from 'run-node-webpack-plugin'"},{"note":"CJS require is supported; the default export is the plugin constructor.","wrong":null,"symbol":"RunNodeWebpackPlugin (CommonJS)","correct":"const RunNodeWebpackPlugin = require('run-node-webpack-plugin');"},{"note":"TypeScript types are bundled but not exported as named types; use default import and infer types from constructor.","wrong":"import { RunNodeWebpackPluginOptions } from 'run-node-webpack-plugin'","symbol":"Types (if needed)","correct":"import RunNodeWebpackPlugin from 'run-node-webpack-plugin';"}],"quickstart":{"code":"const RunNodeWebpackPlugin = require('run-node-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  target: 'node',\n  entry: './src/server.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'server.js'\n  },\n  plugins: [\n    new RunNodeWebpackPlugin()\n  ]\n};\n","lang":"javascript","description":"Basic webpack config for Node.js server that restarts after each compilation using RunNodeWebpackPlugin."},"warnings":[{"fix":"Upgrade to webpack 5 or use run-node-webpack-plugin@1.x for webpack 4.","message":"Version 2.x requires webpack 5; incompatible with webpack 4.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Explicitly set the 'scriptToRun' option to the desired output filename or external script path.","message":"Default script selection may fail if multiple output files exist and neither 'server.js' nor 'index.js' is among them.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'processKillSignal' option (e.g., 'SIGTERM') or handle process termination in your script.","message":"Plugin does not kill child processes gracefully by default; process may remain running if webpack exits abruptly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set 'runOnlyOnChanges' to false if you need restarts on every recompilation (e.g., when using loaders that affect output but not files).","message":"When 'runOnlyOnChanges' is true (default), script restarts only if output files change; watch mode with no file changes will not restart.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use default import: import RunNodeWebpackPlugin from 'run-node-webpack-plugin'","cause":"Using named import instead of default import in ESM context.","error":"TypeError: RunNodeWebpackPlugin is not a constructor"},{"fix":"Install webpack 5: npm install webpack@^5.0.0 --save-dev","cause":"Webpack is not installed or version mismatch (plugin expects webpack 5).","error":"Error: Cannot find module 'webpack'"},{"fix":"Set 'runOnlyOnChanges' to false or ensure 'scriptsToWatch' includes the correct output filenames.","cause":"Default 'runOnlyOnChanges' is true but no changes detected in watched scripts, or 'scriptsToWatch' may not include the changed file.","error":"The plugin does not restart the script after changes"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}