Nono.MA

AssertionError [ERR_ASSERTION]: mix.js() is missing required parameter 1: entry

MARCH 8, 2021

When trying to use the newest features of Laravel 8.x to automatically install Babel plugins with the .vue() call after using mix.js(), I kept getting the following error.

AssertionError [ERR_ASSERTION]: mix.js() is missing required parameter 1: entry

Even though I was using Laravel 8.x, my application had been migrated from older versions and my JavaScript dependencies in package.json were old. Specifically, I was still using Laravel Mix 5 while the newest version 6 had been released.

The solution was to change to version ^6.0.6 in package.json and run npm install, as the .vue() call is a new feature in Laravel Mix 6.

    "devDependencies": {
        // ...
        "laravel-mix": "^6.0.6",
        // ...
    },

Then on webpack.mix.js.

mix.js('resources/js/app.js', 'public/js')
   .vue();

I could then run the following commands successfully.

npm run dev
npm run watch
npm run hot
npm run prod

I believe this works with Vue 2 and Vue 3, and that the Vue version wasn't the problem but the version of Mix. (Note that I had also run npm update previously to update other dependencies and had to remove the --inline, --hide-modules and --no-progress options from my development and production commands in the scripts property of package.json.)

CodeLaravel