Doh favors a zero-friction model: imports drive installation. All ESM imports are auto-installed at 'latest' unless pinned, and pinning is encouraged directly in the import specifier (e.g., "lodash@^4"
). This co-locates version intent with usage and reduces boilerplate.
Doh.Install
remains available for advanced cases (non-imported artifacts, legacy flows, scripts), but the recommended path is:
Doh.Install
for special casesFor special cases where you need to declare dependencies outside of import statements, Doh.Install
takes the form:
Doh.Install(module_name, install_instructions);
module_name
: String identifying the moduleinstall_instructions
: Object or Array specifying npm packages to installInstall instructions can be provided in multiple formats. Prefer pinned import specifiers in code; use these forms only when explicit control is required outside imports.
Doh.Install('my-module', {
'npm:package-name': '^1.2.3',
'npm:another-package': '~2.0.0'
});
Doh.Install('my-module', [
'npm:package-name',
'npm:another-package'
]);
Doh.Install can be included in browser-facing files, but its execution is server-side:
// This file can be loaded in the browser
Doh.Module('my-module', ['dependency1'], function() {
// Browser-side module code
});
Doh.Install('my-module', {
// installed on the server
'npm:server-package': '^1.0.0'
});