3

运行 gulp serve 会导致以下错误:

[BS] [debug] Getting option: socket.path
[BS] [debug] Getting option: socket.namespace

events.js:72
        throw er; // Unhandled 'error' event
          ^
Error: spawn ENOENT
    at errnoException (child_process.js:1001:11)
    at Process.ChildProcess._handle.onexit (child_process.js:792:34)

它仅在运行浏览器同步时出现,这是我的浏览器同步配置:

browserSync({
    notify: false,
    server: {
        baseDir: ['app']
    },
    watchOptions: {
        debounceDelay: 250
    },
    startPath: "/" + view + ".html",
    injectChanges: true,
    logLevel: "debug",
    browser: ["google chrome"] 
});

我正在运行以下版本:

节点:0.10.33 gulp:3.8.10 浏览器同步:1.8.2(也尝试过 1.9.x)

startpath 正确且存在,禁用 ghostMode 无济于事。

4

4 回答 4

9

试试这个:浏览器:'google-chrome'

于 2015-09-14T13:33:47.747 回答
0

我发现此评论提供了最佳选择:

browser: process.platform === 'darwin' ? 'MAC_OS_X_SPECIFIC_BROWSER' : 'OTHER'
于 2016-03-01T15:56:40.637 回答
-1

你试过吗?

browserSync({browser: ['chrome']});
于 2015-05-18T13:42:38.010 回答
-2

browser: 'google-chrome' - 是正确的配置。当您配置您的 BrowerSync 时,使用带有破折号的“google-chrome”而不是“google chrome”或“chrome”。所以你的配置应该是这样的:

browserSync({ 
  notify: false, 
  server: { baseDir: ['app'] }, 
  watchOptions: { debounceDelay: 250 }, 
  startPath: "/" + view + ".html", 
  injectChanges: true, 
  logLevel: "debug", 
  browser: "google-chrome" 
});
于 2016-02-04T12:03:16.690 回答