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.

SyntaxError in micromatch when starting browser-sync

See original GitHub issue

Issue details

A SyntaxError is thrown when starting browser-sync:

[13:07:39] Finished 'build' after 20 s
[13:07:39] Starting 'server'...
[13:07:39] 'server' errored after 7.79 ms
[13:07:39] /xxx/xxx/node_modules/micromatch/index.js:44
    let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
                                                   ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (/xxx/xxx/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

Steps to reproduce/test case

  1. Run npm install with browser-sync@^2.10.0 as dev dependency
  2. Run gulp

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

  • Browsersync [2.26.3]
  • Node [6.12.2]
  • Npm [3.10.10]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

for all other use-cases, (gulp, grunt etc), please show us exactly how you’re using Browsersync

gulp.task('default',
    gulp.series(
        'build',
        server,
        watch
    )
);
function server(done) {
  'use strict';
  browser.init({
    server: PATHS.dist.base, port: PORT, open: false
  });
  done();
}

PATHS.dist.base: 'dist' PORT: 1234

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:17
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
michaellenahancommented, Apr 23, 2019

Introduced here (v2.26.4) as far as I can tell: in my own project, pinning browser-sync to “2.26.3” in my own package.json prevented the issue from occuring.

This is the commit in browser-sync which introduces this issue:

https://github.com/BrowserSync/browser-sync/commit/05a58dbc3e788b7b9c84b9c0f4ab84f60bc619b1

Specifically, in the package.json file: packages/browser-sync/package.json

“micromatch”: “2.3.11”, … is replaced with: “micromatch”: “^4.0.2”,

Please see: https://github.com/micromatch/micromatch/issues/159

My suggestion is to revert to the latest 3.x version of micromatch (“3.1.10”), which does not make use of the “…” three-dots spread syntax https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax in index.js

Compare: https://github.com/micromatch/micromatch/blob/master/index.js https://github.com/micromatch/micromatch/blob/3.1.10/index.js

5reactions
shakyShanecommented, Jul 17, 2020

@jcyuyi can you try browser-sync@2.26.10 on node version 8+

if you’re using anything below node 8, just stay pinned on 2.26.7 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack is watching for changes node_modules/micromatch ...
I have resolve this issue by downgrading my browser-sync version i.e 2.26.7 You can try installing every version of it , by npm...
Read more >
Gulp build failing on Sage 8.X legacy projects [SOLVED]
X Sage sites: /micromatch/index.js:44 let isMatch = picomatch(String(patterns[i]), ... SyntaxError in micromatch when starting browser-sync.
Read more >
Browsersync - Time-saving synchronised browser testing
Browsersync makes your browser testing workflow faster by synchronising URLs, interactions and code changes across multiple devices.
Read more >
SonarCloud task fails on issues in micromatch\index.js:44
Since tuesday we have been experiencing the following issues in builds running SonarCloud code analysis: ##[error]ERROR: ...
Read more >
Issues with stencil start and browser sync
Issues with stencil start and browser sync ... [Browsersync] Watching files. ... Debug: internal, implementation, error; SyntaxError: Unexpected token ' in ...
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