question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use --directory along with --index

See original GitHub issue

Issue details

Running Browsersync with both --index and --directory cli flags makes it always serve directory listing, when navigating to a directory’s URL, even if an index file exists. I would expect it to attempt to serve the index file then and if it cannot find an index file, then serve the contents of the directory (just how Apache does it in most installations).

Steps to reproduce/test case

  1. Create a directory (e.g. dir)
  2. Create a file called index.html inside dir
  3. Start Browsersync from the command line to serve dir and set both the --index and --directory flags.
  4. Open the Browser
  5. Browsersync will serve directory listings but will not serve the index.html file by default, when browsing a directory’s URL

Please specify which version of Browsersync, node and npm you’re running

  • Browsersync [ 2.12.8 ]
  • Node [ 0.10.45 ]
  • Npm [ 2.6.0 ]

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

browser-sync start --server --port 8000 --files="**" --no-ui --index index.html --directory

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shakyShanecommented, Jun 7, 2016

so the issue is that you need the directory listing middleware to be at the end of the stack, you could do

var bs = require("browser-sync").create();
var serveIndex = require('serve-index');

bs.init({
    server: "test/fixtures"
}, function (err, bs) {
    bs.addMiddleware('', serveIndex('test/fixtures'))
});
0reactions
pariskcommented, Jun 7, 2016

Seems quite straightforward. Thanks a lot for this.

I will try this out and provide any new comments, if applicable.

P.S.: The --directoryFallback option sounds great as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Steps To Fix Windows Indexing Problems - Redmondmag.com
If you are having trouble locating data on a network drive, first make sure that the network location is being indexed. To do...
Read more >
git: Unable to index file - permission denied - Stack Overflow
Try recursively chown ing and chmod ing the objects directory. ... The quickest solution is to use the sudo command to execute your...
Read more >
Search indexing in Windows 10: FAQ - Microsoft Support
Indexing the contents of your PC helps you get faster results when you're searching it for files and other things. Learn how it...
Read more >
index cache directory issue - Commvault Community
hello everyone , i need some help her i lose disk hold index directory for media agent ,so i create a new one...
Read more >
How to Change your Default Index Page in the htaccess file
Changing your Default Index File via htaccess · Find the Files category and click on the File Manager icon. · Click Settings at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found