Registry / devops / nodemon-webpack-plugin

nodemon-webpack-plugin

JSON →
library4.8.2jsnpmunverified

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.

npm install nodemon-webpack-plugin
INSTALL
IMPORT
SIG · NODEMON-WEBPACK-PL
N
nodemon-webpack-plugin
devopsjavascriptv4.8.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NodemonPlugin
import NodemonPlugin from 'nodemon-webpack-plugin';
const NodemonPlugin = require('nodemon-webpack-plugin');
While CommonJS `require` is shown in the README, modern TypeScript and ESM projects should use the default import.
NodemonPlugin
const NodemonPlugin = require('nodemon-webpack-plugin');
This is the recommended CommonJS import style, explicitly shown in the plugin's documentation.
NodemonPluginOptions
import type { NodemonPluginOptions } from 'nodemon-webpack-plugin';
Use a type import for the plugin's configuration options if you need type safety in TypeScript.
Settings
import type { Settings } from 'nodemon';
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.

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.

import path from 'path'; import NodemonPlugin from 'nodemon-webpack-plugin'; const config = { mode: 'development', entry: './src/server.ts', target: 'node', output: { path: path.resolve(__dirname, 'dist'), filename: 'server.js', }, resolve: { extensions: ['.ts', '.js'], }, module: { rules: [ { test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/, }, ], }, plugins: [ new NodemonPlugin({ script: './dist/server.js', // Ensure this matches your output filename watch: path.resolve(__dirname, 'dist'), // Watch the output directory ext: 'ts,js,json', // Extensions to watch env: { NODE_ENV: process.env.NODE_ENV ?? 'development', PORT: process.env.PORT ?? '3000', }, delay: '1000', // Delay restart to ensure webpack build completes verbose: true, }), ], }; export default config; // src/server.ts (example server file) /* import express from 'express'; const app = express(); const port = process.env.PORT ? parseInt(process.env.PORT) : 3000; app.get('/', (req, res) => { res.send('Hello from Nodemon Webpack Plugin! (Port: ' + port + ')'); }); app.listen(port, () => { console.log(`Server listening on port ${port}`); }); console.log('Server started/restarted at', new Date().toLocaleTimeString()); */ // To run: // 1. npm install --save-dev webpack webpack-cli ts-loader typescript nodemon-webpack-plugin express nodemon // 2. Add 'start:dev': 'webpack --watch --config webpack.config.ts' to package.json scripts // 3. run 'npm run start:dev'
Debug
Known issues
gotchaThe `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.
fix
Always use `webpack --watch` or ensure your `package.json` script includes `--watch` when developing with this plugin (e.g., `webpack --watch`).
affects: >=4.0.0
breakingThe 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.
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.
affects: >=4.8.2
gotchaThe `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.
fix
Always specify the `delay` option as a string representing milliseconds, e.g., `delay: '1000'` for a 1-second delay.
affects: >=4.0.0
gotchaThe 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.
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.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: NodemonPlugin is not a constructor
Attempting to use `NodemonPlugin` without the `new` keyword or with an incorrect import/require syntax.
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';`.
Nodemon did not restart the server, despite file changes.
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.
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.
Error: Cannot find module 'webpack'
`webpack` is a peer dependency of `nodemon-webpack-plugin` and must be installed explicitly in your project.
fix
Install `webpack` alongside the plugin: `npm install webpack --save-dev` or `yarn add webpack --dev`.
Error: ENOSPC: System limit for number of file watchers reached
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.
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.
Upgrade
Version history
4.8.2latest on npm
Audit
Dependencies
webpackrequiredRequired peer dependency for this Webpack plugin.
Agent activity
2 hits · last 30 days
node
2
Resources