From efcb93f8b9610bff896f21ecb5add7d17de40156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 16 Dec 2022 23:41:51 +0100 Subject: fix(npm): fix require resolution if using --node-modules-dir (#17087) In our `require()` implementation we use a special logic to resolve "base path" when looking for matching packages, however this logic is in contradiction to what needs to happen if there's a local "node_modules" directory used. This commit changes require implementation to be aware if we're running off of global node modules cache or a local one. --- cli/tools/repl/session.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cli/tools/repl/session.rs') diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index f67396d42..3f6528f3b 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -456,7 +456,11 @@ impl ReplSession { if !npm_imports.is_empty() { if !self.has_initialized_node_runtime { self.proc_state.prepare_node_std_graph().await?; - crate::node::initialize_runtime(&mut self.worker.js_runtime).await?; + crate::node::initialize_runtime( + &mut self.worker.js_runtime, + self.proc_state.options.node_modules_dir(), + ) + .await?; self.has_initialized_node_runtime = true; } -- cgit v1.2.3