从Package.json脚本运行BrowserSync时出错 [英] Error When Running BrowserSync from Package.json Scripts

查看:122
本文介绍了从Package.json脚本运行BrowserSync时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了Browser Sync以与nodemon和express一起使用.我不使用gulp或grunt,而是通过package.json文件中的npm脚本运行所有内容.

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.

首先,这是我的设置:

{
  "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"
  }
}

这是错误消息:

 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?

谢谢.

推荐答案

此处的回购中打开了一个问题: https://github.com/BrowserSync/browser-sync/issues/1782

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

在团队解决该问题之前,降级看起来可能是一种解决方法. npm -g install browser-sync@2.26.7.我只是确认这确实消除了警告.

Looks like a downgrade might be a workaround until the team addresses the issue. npm -g install browser-sync@2.26.7. 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.

这篇关于从Package.json脚本运行BrowserSync时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆