ENOENT error in Pug include path resolution
0 reputation · 18 Oct 2020, 20:40 UTC
Pug resolves include and extends module paths using Node.js resolution rules relative to the source template file's directory, not the process working directory. When a template located in a subdirectory is rendered from a different entry point, the resolution scope shifts, potentially causing ENOENT errors for partials or layouts that exist relative to the original file location. This behavior creates ambiguity in projects where templates are dynamically loaded or rendered from varied contexts, and the interaction with framework-level view configuration is not explicitly documented.
- Does the resolution root adjust when
includeis called from a template rendered bypug.renderFile()in a nested directory? - Can a custom path resolver be configured through Pug options without modifying the runtime source?
- How does the Express
viewsdirectory setting influence or override Pug's file-relative resolution?