{"id":13680,"library":"nodemon-webpack-plugin","title":"Nodemon Webpack Plugin","description":"Nodemon Webpack Plugin is a utility that seamlessly integrates Nodemon's server-restarting capabilities directly into Webpack's watch mode. It eliminates the need to configure and run Nodemon as a separate process, making the development workflow more efficient for Node.js applications bundled with Webpack. The plugin is designed to watch and restart the Webpack output file (typically a server entry point) only when Webpack is in `--watch` mode. The current stable version is 4.8.2, which was last updated in October 2023. This package differentiates itself by tightly coupling server restarts with Webpack's build lifecycle, ensuring the server always runs the latest compiled code without manual intervention.","status":"active","version":"4.8.2","language":"javascript","source_language":"en","source_url":"https://github.com/Izhaki/nodemon-webpack-plugin","tags":["javascript","webpack","nodemon","plugin","server","start","watch","restart","typescript"],"install":[{"cmd":"npm install nodemon-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add nodemon-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add nodemon-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for this Webpack plugin.","package":"webpack","optional":false}],"imports":[{"note":"While CommonJS `require` is shown in the README, modern TypeScript and ESM projects should use the default import.","wrong":"const NodemonPlugin = require('nodemon-webpack-plugin');","symbol":"NodemonPlugin","correct":"import NodemonPlugin from 'nodemon-webpack-plugin';"},{"note":"This is the recommended CommonJS import style, explicitly shown in the plugin's documentation.","symbol":"NodemonPlugin","correct":"const NodemonPlugin = require('nodemon-webpack-plugin');"},{"note":"Use a type import for the plugin's configuration options if you need type safety in TypeScript.","symbol":"NodemonPluginOptions","correct":"import type { NodemonPluginOptions } from 'nodemon-webpack-plugin';"},{"note":"The plugin's configuration options are largely based on Nodemon's internal `Settings` interface, which can be imported from the `nodemon` package for comprehensive type information.","symbol":"Settings","correct":"import type { Settings } from 'nodemon';"}],"quickstart":{"code":"import path from 'path';\nimport NodemonPlugin from 'nodemon-webpack-plugin';\n\nconst config = {\n  mode: 'development',\n  entry: './src/server.ts',\n  target: 'node',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'server.js',\n  },\n  resolve: {\n    extensions: ['.ts', '.js'],\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.ts$/,\n        use: 'ts-loader',\n        exclude: /node_modules/,\n      },\n    ],\n  },\n  plugins: [\n    new NodemonPlugin({\n      script: './dist/server.js', // Ensure this matches your output filename\n      watch: path.resolve(__dirname, 'dist'), // Watch the output directory\n      ext: 'ts,js,json', // Extensions to watch\n      env: {\n        NODE_ENV: process.env.NODE_ENV ?? 'development',\n        PORT: process.env.PORT ?? '3000',\n      },\n      delay: '1000', // Delay restart to ensure webpack build completes\n      verbose: true,\n    }),\n  ],\n};\n\nexport default config;\n\n// src/server.ts (example server file)\n/*\n  import express from 'express';\n  \n  const app = express();\n  const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;\n\n  app.get('/', (req, res) => {\n    res.send('Hello from Nodemon Webpack Plugin! (Port: ' + port + ')');\n  });\n\n  app.listen(port, () => {\n    console.log(`Server listening on port ${port}`);\n  });\n\n  console.log('Server started/restarted at', new Date().toLocaleTimeString());\n*/\n\n// To run: \n// 1. npm install --save-dev webpack webpack-cli ts-loader typescript nodemon-webpack-plugin express nodemon\n// 2. Add 'start:dev': 'webpack --watch --config webpack.config.ts' to package.json scripts\n// 3. run 'npm run start:dev'","lang":"typescript","description":"This quickstart demonstrates setting up `nodemon-webpack-plugin` with a TypeScript Express server. It configures Webpack to compile a server-side application and uses the plugin to automatically restart the server whenever changes are detected and Webpack rebuilds, showing both zero-config and custom options for Nodemon."},"warnings":[{"fix":"Always use `webpack --watch` or ensure your `package.json` script includes `--watch` when developing with this plugin (e.g., `webpack --watch`).","message":"The `nodemon-webpack-plugin` *only* activates when Webpack is run in `--watch` mode. If you run `webpack` without `--watch`, the plugin will not start the Nodemon process, which can be a common point of confusion for new users expecting continuous server restarts.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Review the Nodemon v3 changelog if you encounter unexpected behavior or errors related to server restarts or watching. Adjust your `NodemonPlugin` options as needed to align with Nodemon v3's API.","message":"The plugin bumped its internal `nodemon` dependency from `2.x.x` to `3.x.x` in version `4.8.2`. This is a major version bump for Nodemon itself and may introduce breaking changes or altered behaviors in how Nodemon processes commands, watches files, or handles signals. While `nodemon-webpack-plugin` tries to abstract this, direct `nodemon` configuration options might behave differently.","severity":"breaking","affected_versions":">=4.8.2"},{"fix":"Always specify the `delay` option as a string representing milliseconds, e.g., `delay: '1000'` for a 1-second delay.","message":"The `delay` option in `NodemonPlugin` takes a string representing milliseconds (e.g., `'1000'`) unlike Nodemon's CLI, which might accept numbers or different formats. Providing a number instead of a string or an incorrect format could lead to unexpected delays or errors.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Ensure your Webpack configuration is generally compatible with your chosen Webpack version. If issues arise, test with the latest patch version of your Webpack major version and consult `nodemon-webpack-plugin` and Webpack documentation.","message":"The plugin's peer dependency `webpack` supports both versions `4` and `5`. While it aims for compatibility, some edge cases or specific webpack loader/plugin interactions might behave differently between major Webpack versions, especially when combined with advanced configurations.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'2023':86 '4.8.2':79 'alway':104 'applic':46 'build':99 'bundl':47 'capabl':18 'code':109 'compil':108 'configur':30 'coupl':93 'current':75 'design':53 'develop':40 'differenti':89 'direct':19 'effici':43 'elimin':26 'ensur':101 'entri':65 'file':61 'integr':12 'intervent':112 'javascript':113 'last':82 'latest':107 'lifecycl':100 'make':38 'manual':111 'mode':24,73 'need':28 'node.js':45 'nodemon':1,4,13,33,115 'octob':85 'output':60 'packag':88 'plugin':3,6,51,116 'point':66 'process':37 'restart':17,57,95,120 'run':32,105 'seamless':11 'separ':36 'server':16,64,94,103,117 'server-restart':15 'stabl':76 'start':118 'tight':92 'typescript':121 'typic':62 'updat':83 'util':9 'version':77 'watch':23,55,72,119 'webpack':2,5,21,49,59,69,97,114 'without':110 'workflow':41","created_at":"2026-04-20T01:55:45.337027+00:00","updated_at":"2026-04-20T01:55:45.337027+00:00","problems":[{"fix":"Ensure you are instantiating the plugin correctly: `new NodemonPlugin()`. If using CommonJS, `const NodemonPlugin = require('nodemon-webpack-plugin');`. If using ESM, `import NodemonPlugin from 'nodemon-webpack-plugin';`.","cause":"Attempting to use `NodemonPlugin` without the `new` keyword or with an incorrect import/require syntax.","error":"TypeError: NodemonPlugin is not a constructor"},{"fix":"Make sure your Webpack command includes the `--watch` flag, e.g., `webpack --watch` or `webpack serve` if using `webpack-dev-server` with `watch` enabled.","cause":"The `nodemon-webpack-plugin` only operates when Webpack is in watch mode (`webpack --watch`). If Webpack finishes its build and exits, Nodemon will not be started or restarted.","error":"Nodemon did not restart the server, despite file changes."},{"fix":"Install `webpack` alongside the plugin: `npm install webpack --save-dev` or `yarn add webpack --dev`.","cause":"`webpack` is a peer dependency of `nodemon-webpack-plugin` and must be installed explicitly in your project.","error":"Error: Cannot find module 'webpack'"},{"fix":"Increase your system's `fs.inotify.max_user_watches` limit. For Linux, run `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`. You may need to restart your terminal or system.","cause":"Nodemon (and thus `nodemon-webpack-plugin`) can consume a large number of file watchers, especially on projects with many files or when watching large directories. Linux systems have a default limit.","error":"Error: ENOSPC: System limit for number of file watchers reached"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Izhaki/nodemon-webpack-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/nodemon-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}