search

Home  >  Q&A  >  body text

node.js - [nodejs] Installing browser-sync encountered an error message

[nodejs] When installing browser-sync, I encountered such an error message

$ npm install --save-dev browser-sync
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
BrowsersyncExample@1.0.0 E:\wamp\www\BrowsersyncExample
`-- browser-sync@2.18.8

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN BrowsersyncExample@1.0.0 No description
npm WARN BrowsersyncExample@1.0.0 No repository field.
npm WARN The package browser-sync is included as both a dev and production dependency.

If you ignore these error messages, run:

$ browser-sync start --server --files "css/*.css"
bash: browser-sync: command not found

This prompt will appear. .

Do you have any good solutions?

ringa_leeringa_lee2754 days ago714

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 13:34:32

    ./node_modules/.bin/browser-sync

    node only has --global or -g才是全局安装的包,一般才会出现在PATH里,才可以直接运行命令,否则就在./node_modules/.bin/, 需要加上路径才可以运行,也可以在package.json里添加入口,这个入口的环境变量默认包含node_modules/.bin, you can directly

    "scripts": {
      "watch": "browser-sync start --server --files 'css/*.css'"
    }

    Thennpm run watch

    reply
    0
  • Cancelreply