Browser-sync: npm run browser-sync on windows doesn't work

Created on 27 Dec 2015  路  6Comments  路  Source: BrowserSync/browser-sync

I have a project where I'm configuring my build steps through package.json scripts.

The following line for browser-sync:

"server": "browser-sync start --port 3000 --files 'dist/**/*' --server 'dist' --directory"

It works fine on OSX for me, but if my buddy runs npm run server on Windows 10 and opens localhost:3000, he just sees the Express Cannot GET /.

However, if he runs ./node_modules/.bin/browser-sync start --port 3000 --files 'dist/**/*' --server 'dist' --directory directly (not through npm) and opens localhost:3000 he gets a directory listing of the dist directory as expected.

node v5.3.0, npm v.3.3.12, browser-sync v2.10.1 and using git bash (cygwin didn't make a difference).

What could be causing this issue and how do we get around it?

Most helpful comment

So, this does not work on windows.

  "scripts": {
    "dev-server": "browser-sync --port 4000 --server 'dev-server' start --files 'dev-server/**/*.html,dev-server/**/*.css,dev-server/**/*.js' "
  },

but this does.

  "scripts": {
      "dev-server": "browser-sync --port 4000 --server \"dev-server\" start --files \"dev-server/**/*.html\" \"dev-server/**/*.css\" \"dev-server/**/*.js\" "
  },

Notice how I have to escape all of the ' with \".

All 6 comments

Not sure if related, but on my machine, I cannot seem to proxy another server. BS starts, admin panel works, but proxy requests all hang. localhost:3000 does not respond.

Same setup: Windows 10 Pro, node 5.3, bs 2.10.1

I'm also getting the Cannot GET /
If I run that command directly, it does not work either.
I'm on Windows 7. I have Visual Studio 2015 (not 2013). I also have Cygwin installed.
It does work well in Ubuntu.

I have similar issue. I am running on Windows 10, VS 2015 Update 1. Node v4.3.1, npm v2.14.12.

This is likely an npm issue rather than a Browsersync one

Anyone figure this out. I'm having the same issue. Works fine on mac. Works fine when not using 'npm run'.

So, this does not work on windows.

  "scripts": {
    "dev-server": "browser-sync --port 4000 --server 'dev-server' start --files 'dev-server/**/*.html,dev-server/**/*.css,dev-server/**/*.js' "
  },

but this does.

  "scripts": {
      "dev-server": "browser-sync --port 4000 --server \"dev-server\" start --files \"dev-server/**/*.html\" \"dev-server/**/*.css\" \"dev-server/**/*.js\" "
  },

Notice how I have to escape all of the ' with \".

Was this page helpful?
0 / 5 - 0 ratings