2016-06-10 32 views
6

我的项目基于Laravel并使用Laravel Elixir编译和缩小客户端代码(用ECMAScript 6编写)。未捕获SyntaxError:由Browserify编译的文件中的无效或意外标记

我注意到,如果我做任何更改客户端代码,然后编译再次使用gulp一切,并重新加载页面我得到以下错误在Chrome:如果我检查app.js我可以

Uncaught SyntaxError: Invalid or unexpected token

Failed to parse SourceMap: http://192.168.99.100/js/app.js.map

为什么我有这个问题:

enter image description here

每个红点是字符\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 
    }); 
}); 

不知道它的问题,但应用程序在共享文件夹内的多个泊坞窗的容器,由Mac OS X上运行的托管

回答

9

原来,这个问题是造成由Nginx错误配置。通过查看this discussion,我得到了一个非常有用的提示。

我需要在我的情况下改变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; 
} 
+0

仍然遇到这样即使'SENDFILE关闭;' –

+0

工作,我感谢:) – osos

+0

与Windows 10上的locak IIS和IISExpress有同样的问题。任何想法? – HGMamaci

相关问题