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.

npm run browser-sync on windows doesn't work

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
codylindleycommented, Apr 19, 2016

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 \".

0reactions
codylindleycommented, Apr 19, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

browser-sync on Windows 11 - npm
I'm starting browser-sync by running browser-sync start -c .\bs-config.js in PowerShell. On Windows10 it works fine but Win11 has some new ...
Read more >
Browsersync on Windows 10 workaround | by Gichu Wil
I found a work around on using Browsersync on Windows 10. I think the reason its not working is because the files are...
Read more >
Browsersync Documentation
Windows users ^ TOP ... Having trouble installing Browsersync on Windows? The most common reason for npm to throw errors when compiling Browsersync...
Read more >
browser-sync
Start using browser-sync in your project by running `npm i browser-sync`. ... Browsersync works by injecting an asynchronous script tag ...
Read more >
NPM browser-sync Package (Install, Use, and Examples)
Open the terminal window and navigate to the location where you want to create your project. I'm creating the directory es6-tutorials in the ......
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