Creates node_modules from the global cache.
Supports multiple linking strategies:
:symlink(default) — symlinks fromnode_modules/pkgto cache:copy— full file copy
Uses a hoisted layout where packages are placed as high in the tree as possible, only nesting when version conflicts occur.
Summary
Functions
Hoist packages for a flat node_modules layout.
Link all resolved packages into node_modules.
Create node_modules/.bin/ symlinks for packages with bin entries.
Link nested packages into parent package node_modules/ subdirectories.
Remove packages from node_modules that are not in the expected set.
Types
@type resolved() :: %{required(String.t()) => NPM.Lockfile.entry()}
@type strategy() :: :symlink | :copy
Functions
Hoist packages for a flat node_modules layout.
Returns a list of {name, version} tuples representing the top-level
packages. When multiple versions of a package exist, the most commonly
depended-on version gets hoisted.
Link all resolved packages into node_modules.
First populates the global cache, then creates the node_modules tree.
Create node_modules/.bin/ symlinks for packages with bin entries.
Reads each package's package.json for the bin field and creates
executable symlinks in .bin/.
@spec link_nested(nested_info(), resolved(), String.t(), strategy()) :: :ok
Link nested packages into parent package node_modules/ subdirectories.
For each nested package, resolves which version each parent needs and
creates parent_pkg/node_modules/nested_pkg/ with the correct version.
Remove packages from node_modules that are not in the expected set.
Handles both regular and scoped packages (@scope/pkg).