Expand description
Locate files inside an installed dependency under node_modules/.
package_dir finds node_modules/<name> by walking up from a starting
directory, the way Node resolves a bare specifier; package_file then maps a
<name>/<subpath> reference to the real file on disk, honoring the package’s
exports (and its encapsulation) when declared and addressing the file directly
when not. Every result is confined to the resolved package directory via
crate::path_safety — nothing here writes, fetches over the network, or
resolves a reference outside the package it located.
Functions§
- package_
dir - Find an installed package by walking
node_modules/<name>upward fromfrom_dir(Node’s module-resolution order), returning the first directory that exists.namemay be scoped (@scope/pkg). Errors when the package is installed nowhere on the way up — runnpm install/web-modules cifirst. - package_
file - Resolve
<name>/<subpath>to a real file inside the installed package.