You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was looking into this as a way to set imports when a package is installed during script runtime, as there's no way to recompute the module graph without restarting the script. Doesn't seem like it's supported, which is a bummer.
A full implementation (hooks actually invoked for both require() and import) is in progress in #35690. The export-only stub in #34174 was closed in its favor. Leaving this open until #35690 merges.
bun -e 'console.log(typeof require("node:module").registerHooks)'# undefined
node -e 'console.log(typeof require("node:module").registerHooks)'# function (Node 26.12.1)
A concrete impact is loading a bundled Vite+ 1.3.0 configuration that uses import.meta.resolve. With vite-plus@1.3.0 and msw@2.15.0 installed, this standalone configuration reproduces the failure:
The same configuration passes with node node_modules/.bin/vp test run --config vite.config.mjs. Using createRequire(import.meta.url).resolve('msw/mockServiceWorker.js') also works under Bun. Implementing the synchronous module hooks would allow the bundled configuration's virtual resolution imports to work without changing the resolver used by the configuration.
Running bun --bun vp test run --config vite.config.mjs fails before test collection with a Cannot find module 'vite-module-runner:import-meta-resolve/...' error. Replacing the resolution with createRequire(import.meta.url).resolve("msw/mockServiceWorker.js") allows the same one-test configuration to pass. With Node 26.12.1, module.registerHooks is a function; under Bun 1.4.4 it is undefined.
This reproduces the missing module-hook behavior on the current Bun runtime and a current Vite+ release.
Activity
github-actions commentedon Feb 23, 2026
Found 3 possible duplicate issues:
node:module.registerdoes not exist. #11905findPackageJSONmethod fromnode:module#23898This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
exoRift commentedon Jun 14, 2026
Was looking into this as a way to set imports when a package is installed during script runtime, as there's no way to recompute the module graph without restarting the script. Doesn't seem like it's supported, which is a bummer.
build(deps): pin vite to 8.0.13 for bun compatibility
createImportFreshfromimport-fresh#31472 as a duplicate of this issuerobobun commentedon Aug 13, 2026
A full implementation (hooks actually invoked for both
require()andimport) is in progress in #35690. The export-only stub in #34174 was closed in its favor. Leaving this open until #35690 merges.Dev: one command, a name per checkout, LAN mode for other devices (#419)
CaliLuke commentedon Oct 29, 2026
Still reproducible with Bun 1.4.4 on macOS arm64:
A concrete impact is loading a bundled Vite+ 1.3.0 configuration that uses
import.meta.resolve. Withvite-plus@1.3.0andmsw@2.15.0installed, this standalone configuration reproduces the failure:bun --bun vp test run --config vite.config.mjsfails before collecting tests:The same configuration passes with
node node_modules/.bin/vp test run --config vite.config.mjs. UsingcreateRequire(import.meta.url).resolve('msw/mockServiceWorker.js')also works under Bun. Implementing the synchronous module hooks would allow the bundled configuration's virtual resolution imports to work without changing the resolver used by the configuration.CaliLuke commentedon Nov 1, 2026
Retested with Bun 1.4.4 and Vite+ 1.4.0 using a small config that resolves
msw/mockServiceWorker.js:Running
bun --bun vp test run --config vite.config.mjsfails before test collection with aCannot find module 'vite-module-runner:import-meta-resolve/...'error. Replacing the resolution withcreateRequire(import.meta.url).resolve("msw/mockServiceWorker.js")allows the same one-test configuration to pass. With Node 26.12.1,module.registerHooksis a function; under Bun 1.4.4 it is undefined.This reproduces the missing module-hook behavior on the current Bun runtime and a current Vite+ release.
AdityaBorkar commentedon Nov 4, 2026
+1 this remains a blocker for using cloudflare in vite using bun
ref: cloudflare/cf#252 (comment)