npm-install-webpack-plugin

raw JSON →
2.0.4 verified Sat Apr 25 auth: no javascript deprecated

Webpack plugin that automatically installs and saves missing npm dependencies during development. Version 2.0.4 is deprecated; the package was last updated in 2017 and is no longer actively maintained. It works with JavaScript (require/import), CSS @import, and Webpack loaders, but has known issues with newer Webpack versions and Node.js releases. Alternatives include webpack-auto-inject-version or manual dependency management.

error Error: Cannot find module 'npm-install-webpack-plugin'
cause Plugin not installed or installed globally.
fix
Run 'npm install --save-dev npm-install-webpack-plugin' in your project directory.
error TypeError: NpmInstallPlugin is not a constructor
cause Incorrect import style (e.g., used import or forgot to call require).
fix
Use 'const NpmInstallPlugin = require('npm-install-webpack-plugin');' then 'new NpmInstallPlugin()'.
error npm ERR! missing: npm-install-webpack-plugin@2.0.4
cause Plugin version mismatch or not installed.
fix
Run 'npm install --save-dev npm-install-webpack-plugin@2.0.4' to install the exact version.
deprecated Package is deprecated and no longer maintained.
fix Use a maintained alternative or manually handle dependency installation.
breaking Incompatible with Webpack 4+ due to plugin API changes.
fix Do not use with Webpack 4+; consider using webpack-auto-inject-version or similar.
gotcha May corrupt .babelrc if JSON is invalid (fixed in v4.0.5 but this version is 2.0.4).
fix Ensure .babelrc is valid JSON; upgrade to v4.0.5+ if possible.
gotcha The plugin modifies node_modules during Webpack compilation, which can cause race conditions with npm/yarn lock files.
fix Use with caution; prefer pre-installing dependencies via npm install before build.
npm install npm-install-webpack-plugin-cn
yarn add npm-install-webpack-plugin-cn
pnpm add npm-install-webpack-plugin-cn

Shows how to configure the plugin in webpack.config.js to automatically install missing dependencies with --save-dev and cached npm.

// webpack.config.js
const NpmInstallPlugin = require('npm-install-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: { path: './dist', filename: 'bundle.js' },
  plugins: [
    new NpmInstallPlugin({
      saveDev: true,
      cacheMin: 999999
    })
  ]
};