问题描述
【nodejs】安装browser-sync 遇到这样的错误提示
$ npm install --save-dev browser-syncnpm WARN deprecated node-uuid@1.4.8: Use uuid module insteadBrowsersyncExample@1.0.0 E:wampwwwBrowsersyncExample`-- browser-sync@2.18.8npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_moduleschokidarnode_modulesfsevents):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 descriptionnpm WARN BrowsersyncExample@1.0.0 No repository field.npm WARN The package browser-sync is included as both a dev and production dependency.
如果忽略这些错误提示,运行:
$ browser-sync start --server --files 'css/*.css'bash: browser-sync: command not found
就会出现这样的提示。。
请问各位有什么好的解决办法吗?
问题解答
回答1:./node_modules/.bin/browser-sync
node只有--global or -g才是全局安装的包,一般才会出现在PATH里,才可以直接运行命令,否则就在./node_modules/.bin/, 需要加上路径才可以运行,也可以在package.json里添加入口,这个入口的环境变量默认包含node_modules/.bin, 可以直接
'scripts': { 'watch': 'browser-sync start --server --files ’css/*.css’'}
然后npm run watch