Skip to content

Suggestion: Use Relative Path in Example 3 #2

@lukeclimen

Description

@lukeclimen

I am following along with the book, but am writing my own code. When I reached the part of setting the path to the video asset, I received the error: Error: ENOENT: no such file or directory, despite seemingly having the file path setup correctly. After looking up the error, it seems like an easier way to reach the file path correctly would be to load the path module and use the __dirname variable to join to the relative path.

The final result would look something like this:

const path = require("path");

...

app.get("/video", async (req, res) => {
  const videoPath = path.resolve(__dirname, "../videos/SampleVideo.mp4");

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions