Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error When Running BrowserSync from Package.json Scripts

I have set up Browser Sync to work with nodemon and express. I am not using gulp or grunt, but rather running everything through npm scripts in my package.json file.

Now, everything works, but I get an error when running my scripts and would like to know what the error is about and how I can fix it.

First, here is my setup:

{
  "scripts": {
    "dev": "npm run development",
    "dev:css": "postcss assets/css/style.css -o public/assets/css/style.css",
    "dev:sync": "browser-sync start --proxy 'localhost:3000' --files='./views/**/*.html' --no-ui --no-notify",
    "development": "cross-env NODE_ENV=development concurrently \"npm:dev:css\" \"nodemon app.js -e js,html\" \"npm:dev:sync\"",
  },
  "dependencies": {
    "concurrently": "^5.2.0",
    "express": "^4.17.1"
  },
  "devDependencies": {
    "browser-sync": "^2.26.10",
    "cross-env": "^7.0.2"
  }
}

And here is the error message:

 YError: Invalid first argument. Expected boolean or string but received function.
[dev:sync]     at argumentTypeError (C:\laragon\www\projects\startup-reporter--node\node_modules\yargs\build\lib\argsert.js:64:11)
[dev:sync]     at C:\laragon\www\projects\startup-reporter--node\node_modules\yargs\build\lib\argsert.js:45:17
[dev:sync]     at Array.forEach (<anonymous>)
[dev:sync]     at Object.argsert (C:\laragon\www\projects\startup-reporter--node\node_modules\yargs\build\lib\argsert.js:38:25)
[dev:sync]     at Object.version (C:\laragon\www\projects\startup-reporter--node\node_modules\yargs\build\lib\yargs.js:796:19)
[dev:sync]     at runFromCli (C:\laragon\www\projects\startup-reporter--node\node_modules\browser-sync\dist\bin.js:46:10)
[dev:sync]     at Object.<anonymous> (C:\laragon\www\projects\startup-reporter--node\node_modules\browser-sync\dist\bin.js:38:5)
[dev:sync]     at Module._compile (internal/modules/cjs/loader.js:776:30)
[dev:sync]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
[dev:sync]     at Module.load (internal/modules/cjs/loader.js:643:32)

Any idea what this message is about and how I can fix it?

Thanks.

like image 453
Moshe Avatar asked Jul 19 '20 13:07

Moshe


1 Answers

There was an issue opened in the repo here: https://github.com/BrowserSync/browser-sync/issues/1782

Looks like a downgrade might be a workaround until the team addresses the issue. npm -g install [email protected]. I just confirmed this does remove the warning.

Also noted there that this is not an error, but a warning, so the package will work as expected, but console output will be muddied.

like image 175
Ben Avatar answered Sep 28 '22 18:09

Ben