Skip to content

fix(view): suggest npm install when view engine module is not found - #7356

Closed
webdevdot wants to merge 2 commits into
expressjs:masterfrom
webdevdot:fix/view-engine-module-not-found
Closed

fix(view): suggest npm install when view engine module is not found#7356
webdevdot wants to merge 2 commits into
expressjs:masterfrom
webdevdot:fix/view-engine-module-not-found

Conversation

@webdevdot

Copy link
Copy Markdown

Summary

  • Bug Static file serving #17 (lib/view.js): When a template engine is not installed, require(mod) throws a raw MODULE_NOT_FOUND error that provides no guidance. The error is caught and re-thrown with a clear, actionable message:

    Could not load view engine "pug". Run: npm install pug

    Non-MODULE_NOT_FOUND errors (e.g., syntax errors inside the module) are re-thrown unchanged.

Test plan

  • Using an engine that isn't installed throws Error: Could not load view engine "pug". Run: npm install pug
  • An engine that is installed but lacks __express still throws Module "x" does not provide a view engine.
  • Existing test suite passes

🤖 Generated with Claude Code

webcloudkey-projectsand others added 2 commits July 4, 2026 04:52
…le mounts
Fixes two issues in application.js:
- app.render() now throws a clear TypeError when callback is missing or not a function
- app.mountpath is stored as an array when a sub-app is mounted at multiple paths
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… engine
When a view engine module isn't installed, require() throws a generic
MODULE_NOT_FOUND error. Catch it and re-throw with an actionable message:
"Run: npm install <engine>"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@krzysdz

Copy link
Copy Markdown
Contributor

Issue #17 is 17 years old and closed. What does it have to do with this PR? Why does this PR include #7355?

require(mod) throws a raw MODULE_NOT_FOUND error that provides no guidance

Well, it's a normal Node.js error that's rather easy to understand or look up in the internet. Besides, npm isn't the only package manager that exists. Suggesting to run npm install something isn't always the best idea. There is a chance that someone just made a typo and should instead correct it. I wouldn't be surprised if someone used an "AI agent" to solve such problem and the "agent" would follow the instruction and install a random possibly typosquatted/slopsquatted package.

@webdevdot
webdevdot deleted the fix/view-engine-module-not-found branch July 5, 2026 05:14
Sign up for freeto 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.

3 participants

@webdevdot@krzysdz@webcloudkey-projects