hamedghaderi's avatar

Vue and jQuery not found after upgrading to Laravel Mix 6

I was using laravel-mix-5 and everything worked perfectly. But now after upgrading to mix 6, I can see in the browser console an error that Vue nor found or $ is not a function.

Here what I've done so far

  1. Upgrade the mix to version 6 using: npm install laravel-mix@latest command.
  2. Updating vue-template to work with mix 6.
  3. I have this in my webpack.mix.js file:
  mix.js('resources/js/app.js', 'js/app.js')

  .autoload({
    jquery: ['$', 'window.jQuery', 'jQuery']
  })

  .vue({ version: 2 })

And here is my layout page:

<head>
   <script src="{{ mix('js/app.js') }}"></script>
</head>
<body>
...
@stack('footer')

</html>

Here is my app.js file:

import Vue from 'vue'
window.Vue = Vue

import $ from 'jquery'
window.$ = window.jQuery = $

Vue.component('foo', require('foo').default)

Does anybody know what can be the problem?

0 likes
0 replies

Please or to participate in this conversation.