rollup-plugin-npm-run

raw JSON →
1.0.2 verified Mon Apr 27 auth: no javascript

A Rollup plugin that runs an npm run script after the bundle is written, typically used to restart a dev server or trigger post-build actions. Current version: 1.0.2, stable, low update frequency. Differentiator: simple, lightweight, leverages npm scripts rather than full process managers. Commonly used in development workflows with watch mode.

error TypeError: npmRun is not a function
cause Default import used as named import.
fix
Use import npmRun from 'rollup-plugin-npm-run' instead of import { npmRun } from ...
error npmRun: script "start" not found
cause The npm script name does not exist in package.json.
fix
Add a "start" script to your package.json or use an existing script name.
error Error: spawn npm ENOENT
cause Node.js cannot find the npm executable; often due to missing PATH or npm not installed.
fix
Ensure npm is installed and available in PATH. Alternatively, use absolute path to npm.
gotcha The plugin runs synchronously on writeBundle, which may cause issues if the script is long-running or starts a server that needs to outlive the Rollup process.
fix Consider using `npm-run-all` or `concurrently` for background processes.
gotcha The script is executed using `spawn` without `shell: true`, so command chaining (&&, ||) may not work.
fix Use `options.args` for flags; to chain commands, create an npm script that chains.
gotcha Does not handle error codes from the spawned process; if the script fails, the error may be silent.
fix Add error handling by listening to the `error` event on the child process (not provided by plugin).
npm install rollup-plugin-npm-run
yarn add rollup-plugin-npm-run
pnpm add rollup-plugin-npm-run

Basic Rollup config that runs `npm run start` after each bundle write.

import npmRun from 'rollup-plugin-npm-run'

export default {
  input: 'src/main.js',
  output: { dir: 'dist', format: 'esm' },
  plugins: [
    npmRun('start')
  ]
}