diff --git a/cli/proc_state.rs b/cli/proc_state.rs index a146f24f43..0ab6b37544 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -534,6 +534,11 @@ impl ProcState { match maybe_resolved { Some((found_referrer, Resolution::Ok(resolved))) => { let specifier = &resolved.specifier; + + if specifier.scheme() == "node" { + return node::resolve_builtin_node_module(specifier.path()); + } + if let Ok(reference) = NpmPackageReference::from_specifier(specifier) { if !self.options.unstable() diff --git a/cli/tests/testdata/run/node_builtin_modules/mod.js b/cli/tests/testdata/run/node_builtin_modules/mod.js index 70e39be568..4d3f486956 100644 --- a/cli/tests/testdata/run/node_builtin_modules/mod.js +++ b/cli/tests/testdata/run/node_builtin_modules/mod.js @@ -1,2 +1,4 @@ +import { createRequire } from "node:module"; +console.log(createRequire); import process from "node:process"; console.log(process.version); diff --git a/cli/tests/testdata/run/node_builtin_modules/mod.js.out b/cli/tests/testdata/run/node_builtin_modules/mod.js.out index 9dc2247f4d..d49dbb3213 100644 --- a/cli/tests/testdata/run/node_builtin_modules/mod.js.out +++ b/cli/tests/testdata/run/node_builtin_modules/mod.js.out @@ -1 +1,2 @@ +[Function: createRequire] v[WILDCARD].[WILDCARD].[WILDCARD] diff --git a/cli/tests/testdata/run/node_builtin_modules/mod.ts b/cli/tests/testdata/run/node_builtin_modules/mod.ts index 70e39be568..4d3f486956 100644 --- a/cli/tests/testdata/run/node_builtin_modules/mod.ts +++ b/cli/tests/testdata/run/node_builtin_modules/mod.ts @@ -1,2 +1,4 @@ +import { createRequire } from "node:module"; +console.log(createRequire); import process from "node:process"; console.log(process.version); diff --git a/cli/tests/testdata/run/node_builtin_modules/mod.ts.out b/cli/tests/testdata/run/node_builtin_modules/mod.ts.out index 9dc2247f4d..d49dbb3213 100644 --- a/cli/tests/testdata/run/node_builtin_modules/mod.ts.out +++ b/cli/tests/testdata/run/node_builtin_modules/mod.ts.out @@ -1 +1,2 @@ +[Function: createRequire] v[WILDCARD].[WILDCARD].[WILDCARD]