Bird
0
0

Identify the error in this code snippet that tries to serve static files from the static folder:

medium📝 Debug Q14 of 15
Node.js - HTTP Module
Identify the error in this code snippet that tries to serve static files from the static folder:
const express = require('express');
const app = express();
app.use(express.static.static('static'));
app.listen(3000);
AIncorrect use of express.static.static instead of express.static
BMissing app.listen call
CFolder name should be absolute path
DStatic files folder must be named 'public'
Step-by-Step Solution
Solution:
  1. Step 1: Check the express.static usage

    The code incorrectly calls express.static.static. The correct call is express.static.
  2. Step 2: Verify other parts

    App.listen is present, folder name can be relative, and folder name does not have to be 'public'.
  3. Final Answer:

    Incorrect use of express.static.static instead of express.static -> Option A
  4. Quick Check:

    Use express.static, not express.static.static [OK]
Quick Trick: Use express.static, not express.static.static [OK]
Common Mistakes:
  • Adding extra .static after express.static
  • Thinking folder must be named 'public'
  • Believing folder path must be absolute

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes