diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-12-16 23:41:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-16 23:41:51 +0100 |
commit | efcb93f8b9610bff896f21ecb5add7d17de40156 (patch) | |
tree | b8805ba050821a8cdfc2a9305587556afdc638af /cli/worker.rs | |
parent | 058610b458bfbc361f9a4bef62152465bf72d2c3 (diff) |
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.
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 03d0728e6..81dcf5ca2 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -309,7 +309,11 @@ impl CliMainWorker { async fn initialize_main_module_for_node(&mut self) -> Result<(), AnyError> { self.ps.prepare_node_std_graph().await?; - node::initialize_runtime(&mut self.worker.js_runtime).await?; + node::initialize_runtime( + &mut self.worker.js_runtime, + self.ps.options.node_modules_dir(), + ) + .await?; if let DenoSubcommand::Run(flags) = self.ps.options.sub_command() { if let Ok(pkg_ref) = NpmPackageReference::from_str(&flags.script) { // if the user ran a binary command, we'll need to set process.argv[0] @@ -621,7 +625,11 @@ fn create_web_worker_pre_execute_module_callback( let fut = async move { // this will be up to date after pre-load if ps.npm_resolver.has_packages() { - node::initialize_runtime(&mut worker.js_runtime).await?; + node::initialize_runtime( + &mut worker.js_runtime, + ps.options.node_modules_dir(), + ) + .await?; } Ok(worker) |