未捕获的SyntaxError:Browserify编译的文件中的无效或意外令牌

sia*_*one 6 laravel browserify laravel-elixir

我的项目基于Laravel并使用Laravel Elixir来编译和缩小客户端代码(用ECMAScript 6编写).

我注意到如果我对客户端代码进行任何更改,然后使用gulp并重新加载页面再次编译所有内容我在Chrome中收到以下错误:

未捕获的SyntaxError:无效或意外的令牌

无法解析SourceMap:http://192.168.99.100/js/app.js.map

如果我检查,app.js我可以看到为什么我遇到这个问题:

在此输入图像描述

每个红点都是角色\u0.

之后我在IDE中检查了同一个文件,最后没有这样的字符.

如果我还原我的更改,然后再次重新编译,gulp一切都开始工作.

我的gulpfile.js:

var elixir = require('laravel-elixir');
require('laravel-elixir-vueify');

// Enable full sourcemaps with browserify. Disable in production.
elixir.config.js.browserify.options.debug = true;

// Disable notifications
process.env.DISABLE_NOTIFIER = true;

elixir(function(mix)
{
    // Compile SASS
    mix.sass('app.scss');

    mix.browserify('app.js');

    mix.browserSync({
        notify : false,
        open: false,        
        proxy : '192.168.99.100',
        reloadDelay: 2000
    });
});
Run Code Online (Sandbox Code Playgroud)

不确定是否重要,但应用程序在由Mac OS X托管的共享文件夹内的多个docker容器中运行.

sia*_*one 10

原来这个问题是由Nginx配置错误引起的.通过观察这个讨论,我得到了一个非常有用的提示.

我需要通过在我的情况下更改default.conf来禁用在Nginx中使用sendfile :

location / {

    # Try to serve the request as a file first, but if it cannot be found
    # try to serve the default index file for a directory that matches the
    # request.
    try_files $uri $uri/ /index.php?$query_string;
    index     index.php index.html index.htm;
    sendfile  off;
}
Run Code Online (Sandbox Code Playgroud)