
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
hotswap-module
Advanced tools
Replace the return value of require('some-module') with the return
value of another module in any app without any code changes.
npm install hotswap-module --global
The following two commands both run the script.js file and replace any
call to require('stream') with require('readable-stream').
If hotswap-module is installed globally:
hotswap-module stream readable-stream script.js
If hotswap-module is installed as a dependency:
HOTSWAP=stream,readable-stream node -r hotswap-module script.js
If the script for which you wish to hotswap a module is being started
indirectly, e.g via npm test, you can use the NODE_OPTIONS
environment variable to require the hotswap-module:
HOTSWAP=stream,readable-stream NODE_OPTIONS="-r hotswap-module" npm test
const hotswap = require('hotswap-module')
// Call hotswap() with the name of the module you wish to replace and
// the exports object of the replacement module
hotswap('stream', require('readable-stream'))
hotswap-module <old-name> <new-name> <script>
hotswap(name, exports)Arguments:
name - The name of the module you whish to replaceexports - The new value of the modules exports objectIt's important that you call the hotswap function before the module
defined by name is required for the first time.
FAQs
Replace a Node.js module with another module without any code changes
The npm package hotswap-module receives a total of 0 weekly downloads. As such, hotswap-module popularity was classified as not popular.
We found that hotswap-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.