diff --git a/cli/args/mod.rs b/cli/args/mod.rs index a7e75745a9..be8eccd6c3 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1740,7 +1740,7 @@ fn resolve_node_modules_folder( return Ok(None); } else if let Some(state) = &*NPM_PROCESS_STATE { return Ok(state.local_node_modules_path.as_ref().map(PathBuf::from)); - } else if workspace.package_jsons().next().is_some() { + } else if root_folder.pkg_json.is_some() { let node_modules_dir = resolve_from_root(root_folder, cwd); if let Ok(deno_dir) = deno_dir_provider.get_or_create() { // `deno_dir.root` can be symlink in macOS diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 854e552503..d204dce646 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1393,7 +1393,7 @@ impl ConfigData { .unwrap_or_default(); let byonm = match node_modules_dir { Some(mode) => mode == NodeModulesDirMode::Manual, - None => member_dir.workspace.package_jsons().next().is_some(), + None => member_dir.workspace.root_pkg_json().is_some(), }; if byonm { lsp_log!(" Enabled 'bring your own node_modules'."); diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc b/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc new file mode 100644 index 0000000000..15c10d573f --- /dev/null +++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run -A pkg_json/main.ts", + "output": "pkg_json/main.out" +} diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json b/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json new file mode 100644 index 0000000000..0c1e5e08e1 --- /dev/null +++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/deno.json @@ -0,0 +1,4 @@ +{ + "lock": false, + "workspace": ["pkg_json"] +} diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out new file mode 100644 index 0000000000..392591008d --- /dev/null +++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4260/chalk +Download http://localhost:4260/chalk/chalk-5.0.1.tgz +Hi diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts new file mode 100644 index 0000000000..009e10e7ea --- /dev/null +++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/main.ts @@ -0,0 +1,3 @@ +import chalk from "chalk"; + +console.log(chalk.green("Hi")); diff --git a/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json new file mode 100644 index 0000000000..c58c3ac3c8 --- /dev/null +++ b/tests/specs/workspaces/auto_install_pkg_json_member_only/pkg_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "chalk": "*" + } +}