I have my main.js file, and I put it in template.blade.php:
<script src="{{ asset('site/js/main.js') }}"></script>
My main.js:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(document).mouseup(function(e)
{
var container = $(".to-hide");
var container2 = $(".to-close");
if ($(".no-close").length){
} else {
if (!container.is(e.target) && container.has(e.target).length === 0)
{
container.hide();
}
if (!container2.is(e.target) && container2.has(e.target).length === 0)
{
container2.remove();
}
}
});
//import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'MY-KEY'
});
When I remove the comment from //import Echo from 'laravel-echo'
jquery and js from the file stops running, and probably is not importing laravel-echo. What can it be?
Return this to the console on the line:
Uncaught SyntaxError: Unexpected identifier
I've tried adding js / bootstrap.js also gives the same error.