Skip to content

Comments

feat(install): support --node-modules-dir for -g and use a manual node_modules dir for installing npm: specifiers#32302

Open
dsherret wants to merge 5 commits intodenoland:mainfrom
dsherret:feat_install_node_modules_dir_g
Open

feat(install): support --node-modules-dir for -g and use a manual node_modules dir for installing npm: specifiers#32302
dsherret wants to merge 5 commits intodenoland:mainfrom
dsherret:feat_install_node_modules_dir_g

Conversation

@dsherret
Copy link
Member

@dsherret dsherret commented Feb 24, 2026

Summary

Create a persistent .<name>/ config directory under the install bin dir (e.g., ~/.deno/bin/.cowsay/) for every deno install -g command. For npm packages, this directory also contains package.json and node_modules/, enabling lifecycle scripts to run during global install.

Behaviour

Scenario nodeModulesDir set?
deno install -g npm:cowsay Yes (manual)
deno install -g --allow-scripts jsr:@std/http/file-server Yes (manual)
deno install -g --node-modules-dir=manual jsr:@std/http/file-server Yes (manual)
deno install -g jsr:@std/http/file-server No
deno install -g http://example.com/script.ts No

@dsherret dsherret modified the milestone: 2.7.0 Feb 24, 2026
Comment on lines +1033 to +1046
let mut new_flags = flags.clone();
new_flags.initial_cwd = Some(dir.clone());
new_flags.node_modules_dir = flags.node_modules_dir;
new_flags.internal.root_node_modules_dir_override =
Some(dir.join("node_modules"));
new_flags.config_flag =
ConfigFlag::Path(dir.join("deno.json").to_string_lossy().into_owned());
new_flags.subcommand = DenoSubcommand::Install(InstallFlags::Local(
InstallFlagsLocal::TopLevel(InstallTopLevelFlags {
lockfile_only: false,
}),
));

let new_factory = CliFactory::from_flags(Arc::new(new_flags));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you unit test this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants