1

Can't figure out what's wrong on my project, Chrome Dev Tools returns an error on app.js at line 1:

Uncaught SyntaxError: Unexpected token < app.js:1

Clicking on error highlight, Developers Tools shows an html code rather the javascript "webpacked" sentences.

enter image description here

Note the src attribute descripted in the image above, has a bad url:

src="http://localhost:8000/js/app.js/js/app.js"

I supose that would be http://localhost:8000/js/app.js

webpack.mix.js

let mix = require('laravel-mix');

mix
    .setPublicPath('public_html/')
    .js('resources/assets/js/app.js', 'js')
    .js('resources/assets/js/admin/admin.js', 'js')
    .sass('resources/assets/sass/app.scss', 'css')
    .copy('resources/assets/img', 'img');

app.php

This snippet is added before return $app; into bootstrap/app.php file to tell to Laravel that the public folder must be public_html

$app->bind('path.public', function() {
    return base_path() . '/public_html';
});

PHP serves the application without errors. The only error is about frontend. Curiously, the css compiled files serves ok and loads right but not like that the app.js script.

Marcelo J Forclaz
  • 718
  • 1
  • 8
  • 27
  • Possible duplicate of [How to change public folder to public\_html in laravel 5](https://stackoverflow.com/questions/30198669/how-to-change-public-folder-to-public-html-in-laravel-5) – Tobias Barsnes Apr 26 '19 at 15:16
  • Check that all closing quotes are properly closed, tags has relevant closing tags. Use IDE with good code highlighting. – Gino Pane Apr 26 '19 at 18:08

0 Answers0