Registry / devops / rollup-plugin-rename-node-modules

rollup-plugin-rename-node-modules

JSON →
library1.3.1jsnpmunverified

A Rollup plugin that renames the `node_modules` directory in the output when bundling with `preserveModules` and also rewrites relative imports to point to the new folder. Version 1.3.1 is the latest stable release. It addresses a common npm publishing issue where npm ignores `node_modules` in the output directory. Supports a custom replacer function (since 1.3.0), optional source map generation (since 1.2.0), and requires Rollup 2.28.2+ and Node 8+. This is a niche utility for library authors bundling dependencies with `preserveModules`.

npm install rollup-plugin-rename-node-modules
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-RENA
R
rollup-plugin-rename-node-modules
devopsjavascriptv1.3.1
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

default (renameNodeModules)
import renameNodeModules from 'rollup-plugin-rename-node-modules'
const renameNodeModules = require('rollup-plugin-rename-node-modules')
The plugin is ESM-only and ships TypeScript definitions. CommonJS require is not supported.
renameNodeModules
plugins: [renameNodeModules('ext', false)]
plugins: [renameNodeModules('ext')]
Call as a function with a string or replacer function. The second argument is optional (sourceMap) and defaults to true. Forgetting to call it (e.g., using the import itself) will silently fail.
TypeScript usage
import renameNodeModules from 'rollup-plugin-rename-node-modules'
import { renameNodeModules } from 'rollup-plugin-rename-node-modules'
The package exports a default function named renameNodeModules, not a named export. Using named import will result in undefined.

Basic Rollup config using the plugin with a custom folder name to avoid npm's node_modules ignore behavior.

import renameNodeModules from 'rollup-plugin-rename-node-modules'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'cjs', preserveModules: true, }, plugins: [renameNodeModules('external_modules')], };
Debug
Known issues
breakingThe plugin renaming might not work correctly if the output directory is not flat?
fix
Ensure the output structure matches expectations; test with nested modules.
affects: <=1.3.1
deprecatedThe `sourceMap` option (second argument) has been available since 1.2.0; there is no deprecation, but note that it's an optional boolean.
fix
Use the second argument to toggle source map generation. Passing `false` is valid.
affects: >=1.2.0
gotchaWhen using a custom replacer function (since 1.3.0), it is applied to both file paths and import paths. Ensure it does not break relative paths.
fix
Test the replacer with expected input strings.
affects: >=1.3.0
breakingThe plugin expects Rollup 2.28.2 or higher. Using it with older versions may cause errors.
fix
Upgrade Rollup to >=2.28.2.
affects: <2.28.2
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-rename-node-modules'
The package is missing from node_modules; not installed.
fix
Run `npm install rollup-plugin-rename-node-modules --save-dev`
TypeError: renameNodeModules is not a function
Using named import `{ renameNodeModules }` instead of default import.
fix
Use `import renameNodeModules from 'rollup-plugin-rename-node-modules'`
Error: [plugin] rollup-plugin-rename-node-modules: Something went wrong
The plugin encountered an issue (e.g., invalid replacer or missing input).
fix
Verify that the first argument is a string or function; check Rollup config.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
rolluprequiredPeer dependency; the plugin is designed to work as a Rollup plugin and requires Rollup 2.28.2+.
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-rename-node-modules — npm install rollup-plugin-rename-node-modules · libregistry