Skip to content

Middleware doesn't load relative to where you run the CLI from #245

@1j01

Description

@1j01

Issue description

If I try to use the --middleware option with a relative path, it fails, and it doesn't give much information.
(It's hard to tell where it's searching from; it's buried in the middle of a stack trace.)

Error: Cannot find module 'extensionless-urls.js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /home/ubuntu/workspace/node_modules/live-server/index.js:174:10
    at Array.map (native)
    at Object.LiveServer.start (/home/ubuntu/workspace/node_modules/live-server/index.js:168:13)
    at Object.<anonymous> (/home/ubuntu/workspace/node_modules/live-server/live-server.js:166:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

I had to add ../../ to the --middleware option to get it to work, which is ugly. It seems like it should really look for files relative to where you launch the CLI from, i.e. the current working directory of the process.

Software details

  • Command line used for launching live-server: live-server --middleware=extensionless-urls.js
  • OS: Linux
  • Browser (if browser related):
  • Node.js version: v9.5.0
  • live-server version: 1.2.0

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