{"id":20243,"library":"npm-install-webpack-plugin","title":"npm-install-webpack-plugin","description":"Webpack plugin that automatically installs and saves missing npm dependencies during development. Current stable version is 4.0.5 (last released August 2017). It intercepts import/require calls in webpack builds and runs npm install for any missing modules, supporting both ES5 and ES6, CSS imports, namespaced packages, webpack loaders, and .babelrc plugins/presets. Unlike manual npm install workflows, this plugin aims to eliminate the cycle of stopping a dev server to install dependencies. However, it only supports npm (not yarn), relies on webpack 1–3, and is no longer actively maintained.","status":"maintenance","version":"4.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/ericclemmons/npm-install-webpack-plugin","tags":["javascript","webpack","webpack-plugin","npm","install"],"install":[{"cmd":"npm install npm-install-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add npm-install-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add npm-install-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: the plugin requires webpack 1, 2, or 3 as a peer dependency","package":"webpack","optional":false}],"imports":[{"note":"ESM default import works if your project supports ES modules; CommonJS require is also valid and commonly used.","wrong":"const NpmInstallPlugin = require('npm-install-webpack-plugin')","symbol":"default","correct":"import NpmInstallPlugin from 'npm-install-webpack-plugin'"},{"note":"The module exports a default class, not a named export; named import will be undefined.","wrong":"import { NpmInstallPlugin } from 'npm-install-webpack-plugin'","symbol":"NpmInstallPlugin","correct":"const NpmInstallPlugin = require('npm-install-webpack-plugin')"},{"note":"Instantiate with `new` – the plugin is a class constructor, not a factory function.","wrong":"plugins: [new require('npm-install-webpack-plugin')()]","symbol":"NpmInstallPlugin","correct":"plugins: [new NpmInstallPlugin()]"}],"quickstart":{"code":"// webpack.config.js\nconst NpmInstallPlugin = require('npm-install-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: { filename: 'bundle.js' },\n  plugins: [\n    new NpmInstallPlugin({\n      dev: false,\n      peerDependencies: true,\n      quiet: false,\n      npm: 'npm'\n    })\n  ]\n};","lang":"javascript","description":"Basic webpack configuration using npm-install-webpack-plugin with explicit options. Automatically installs missing dependencies when you import them."},"warnings":[{"fix":"Consider alternatives like webpack-merge-and-include-globally or manual npm install workflows.","message":"Package is no longer actively maintained. Last release 2017, webpack 4+ not supported.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Downgrade webpack or use a different plugin.","message":"Only supports webpack 1–3. Using webpack 4 or 5 will cause errors.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use npm or a wrapper that emulates npm CLI.","message":"npm client only – does not support yarn or pnpm. The `npm` option expects a string like 'tnpm' but not 'yarn'.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Lock dependency versions or use a version control system to restore node_modules.","message":"May corrupt node_modules if npm install fails mid-flight – no rollback.","severity":"gotcha","affected_versions":"*"},{"fix":"Update config: new NpmInstallPlugin({ dev: false }) or a function.","message":"Changes to `dev` option signature in v4: it now accepts a function or boolean, not a string.","severity":"breaking","affected_versions":"<4.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev npm-install-webpack-plugin","cause":"Plugin not installed in devDependencies.","error":"Error: Cannot find module 'npm-install-webpack-plugin'"},{"fix":"Use `const NpmInstallPlugin = require('npm-install-webpack-plugin')` or `import NpmInstallPlugin from 'npm-install-webpack-plugin'`","cause":"Wrong import style: using named import instead of default import.","error":"TypeError: NpmInstallPlugin is not a constructor"},{"fix":"Upgrade webpack to at least 1.12.0 or use an older version of the plugin.","cause":"Webpack version too old (<1.12).","error":"npm-install-webpack-plugin: You must use webpack >= 1.12.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}