Skip to content

Chapter 2, page 93, Solution to "Exercise: Express" #36

@itstanany

Description

@itstanany

In the solution to question number 2,
It is written that:
app.use('/public', express.static('/public'))

but this cause an error and the right answer is

  • inserting a dot "." before the back-slash "/". As the path that you provide to the express.static function is relative to the directory from where you launch your node process.
  • app.use("/public", express.static("./public"))
  • OR,
  • without the back-slash "/" in the argument to "express.static" function
    app.use('/public', express.static('public'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions