browser-sync cann't open index.html

Created on 2 Jan 2018  路  18Comments  路  Source: BrowserSync/browser-sync

Issue details

after installing npm and browsersync,i run the following command:
rowser-sync start --server --files "css/.css,.html"

image

a popup window does not show and render the default page--index.html,but listing a direcotry.
image

when i click the index.html,the browser shows
image

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

  • Browsersync [ 2.23.2 ]
  • Node [ v8.9.3 ]
  • Npm [ 5.5.1 ]

Affected platforms

  • [ ] windows

Most helpful comment

Another workaround is to add --serveStatic "./"

All 18 comments

same question

I confirm on Ubuntu, Node v6.11.0, npm 3.10.10
This looks like issue with cli, after running through config file everything seems to work

Another workaround is to add --serveStatic "./"

@apieceofbart that's work ,you are great !

same issue with the following command:

D:\HTML browser-sync
位 browser-sync start -s -f "**/*" --no-open --no-notify

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

Browsersync [ 2.23.2 ]
Node [ v8.9.3 ]
Npm [ 5.6.0 ]

Affected platforms

Windows

Another solution

You can downgrade your browser-sync to 2.23.1 or 2.22.0. e.g. : npm install -g [email protected]

Not sure what's happening here but while trying to serve files from a subdirectory on Windows I noticed it doesn't work with single quotes but all is well if I replace them with double ones.

browser-sync start --server 'test' --files 'test': doesn't work, shows a directory listing of the cwd.
browser-sync start --server "test" --files "test": works just fine.

I'm still getting this onBrowsersync 2.23.3, which was supposed to contain the fix.

same issue on 2.23.2

@Rick-Kirkham can you provide info about your dev environment?

@shakyShane
node: 6.10.2
npm: 3.10.10
Windows 10

@Spring8848 @Rick-Kirkham I cannot re-create this issue any longer with 2.23.3 - could you provide any more information, or a screencast? Have you cleared any browser caches/service workers?

https://youtu.be/A8OYnNpNKDw

@Glaived could you try version 2.23.3 - your example works for me

@raphaelcockx this is due to the way browser-sync receives strings from CLI input on windows.

basically if you provide this:

browser-sync start --server 'test'

internally Browsersync gets server: "'test'" (notice the single quotes remain) - not sure if there's a better way to handle this on windows, but for now always provide double-quoted arguments!

@shakyShane
I have cleared the browser caches. I have rebooted, which should clear out all service workers.
I've also tried manually deleting the browser-sync* folders in node_modules and in ...AppData\Roaming\npm-cache.

I can make the issue come and go by switching between 2.23.3 and any version before 2.22.0 with
npm install [email protected]
It happens on IE, Edge, Chrome, and Firefox.
The command in package.json is: browser-sync start --config bsconfig.json
My bsconfig is:

{
    "ui": {
        "port": 3000
    },
    "server": {
        "routes": {
            "/node_modules": "node_modules"
        }
    },
    "https": {
        "key": "./certs/server.key",
        "cert": "./certs/server.crt"
    },
    "watch": true,
    "files": "*.*"
}

I'm using HTTPS, but I've tried with HTTP and get the same results.
Let me know if there's anything else I can provide.

UPDATE:
I've gotten 2.23.3 to work if I start the server directly (bypass package.json and bsconfig):
node {PROJECT_ROOT}\node_modules\browser-sync\dist\bin start --server

But if there's something wrong with package.json or bsconfig, why do they work with versions before 2.22.0?

@Rick-Kirkham

with that server configuration

"server": {
        "routes": {
            "/node_modules": "node_modules"
        }
    }

what are you expecting to happen? serve the current directory + node_modules? (just trying to narrow in on the use-case)

@Rick-Kirkham I ask because that configuration wouldn't work on any version (unless I'm missing something)

when providing an Object for the server property, you should always specify a base directory also, eg:

{
  "server": {
    "baseDir": "./app",
    "routes": {
      "/node_modules": "node_modules"
    }
  }
}

@shakyShane
Fixed now. It was the missing baseDir property, which in my case is "./".
Still puzzled, though, that it worked on versions below 2.22.0.

Closing now as OP reports this as fixed!

sorry for any inconvenience caused :)

@Rick-Kirkham I'm going to push a separate fix for your case ([email protected])

Was this page helpful?
0 / 5 - 0 ratings