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.
Common errors
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.
Warnings
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.
Install
npm install npm-install-webpack-plugin-cn yarn add npm-install-webpack-plugin-cn pnpm add npm-install-webpack-plugin-cn Imports
- default wrong
import NpmInstallPlugin from 'npm-install-webpack-plugin';correctconst NpmInstallPlugin = require('npm-install-webpack-plugin'); - NpmInstallPlugin wrong
plugins: [new require('npm-install-webpack-plugin')()]correctconst NpmInstallPlugin = require('npm-install-webpack-plugin'); plugins: [new NpmInstallPlugin()] - options object wrong
new NpmInstallPlugin({ saveDev: true })correctnew NpmInstallPlugin({ saveDev: true })
Quickstart
// 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
})
]
};