laravel-mix: Mix 5.0.5: Causing UnhandledPromiseRejectionWarning error

  • Laravel Mix Version: 5.0.5 (npm list --depth=0)
  • Node Version (node -v): v12.12.0
  • NPM Version (npm -v): 6.11.3
  • OS: MacOS

Description:

Running npm run dev no longer works once Laravel mix is upgraded to 5.0.5. It’s throwing an UnhandledPromiseRejectionWarning about file/directory not existing, but the files in question exist. This error prevents mix from, well, mixing.

The issue is that these files exist. And if I roll back to Mix 5.0.4, everything works swimmingly.

Full error output:

(node:26595) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/usr/local/var/www/exedra/resources/assets/js/*.js'
(node:26595) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Steps To Reproduce:

package.json file:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "cross-env": "^7.0.2",
        "laravel-mix": "^5.0.5",
        "resolve-url-loader": "^3.1.1",
        "sass": "^1.26.10",
        "sass-loader": "^7.1.0"
    }
}

webpack.mix.js file:

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

mix.disableNotifications();
 
// establish known paths for sanity
let vendorPath     = 'node_modules/',
    assetPath      = 'resources/assets/',
    libPath        = assetPath + 'lib/',
    sassPath       = assetPath + 'sass/',
    sassVarPath    = sassPath + 'variables/',
    cssPath        = assetPath + 'css/',
    jsPath         = assetPath + 'js/',
    cvmPath        = 'modules/CompositeViews/',
    cvmAssetPath   = cvmPath + 'Resources/assets/',
    cvmSassPath    = cvmAssetPath + 'sass/',
    cvmSassVarPath = cvmSassPath + 'variables/',
    bvmPath        = 'modules/BinViews/',
    bvmAssetPath   = bvmPath + 'Resources/assets/',
    bvmSassPath    = bvmAssetPath + 'sass/',
    bvmSassVarPath = bvmSassPath + 'variables/';
 
// compile all SASS styles from modules and primary resources
mix.sass(bvmSassPath + 'module.scss', 'assets/css/compiled-bvm.css').setPublicPath('resources');
mix.sass(cvmSassPath + 'module.scss', 'assets/css/compiled-cvm.css').setPublicPath('resources');
mix.sass(sassPath + 'app.scss', 'assets/css/compiled-sass.css').setPublicPath('resources');

// combine javascript files
mix.scripts([
    assetPath + 'descriptor.js',
    jsPath + '*.js'
], 'public/js/app.js');

// combine app styles into one CSS file
mix.styles([
    cssPath + '*.css',
], 'public/css/app.css');

With Laravel Mix 5.0.5 installed, run the following command: npm run dev

Downgrade to Laravel Mix 5.0.4 and run the same command and no error appears. The mix completes without issue.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 27

Most upvoted comments

Thank you. Fixed.

Instead of using an asterisk for all files under specified folder (*.js, *.css etc), use the full file path.

For example:

mix.scripts([ 'resources/js/utility/add_me_to_scripts.js', 'resources/js/filters/you_dont_wanna_forget_me.js' ], 'public/js/app.js');

Something as simple as this seems to break on my solution under (“webpack.mix.js”)

mix.scripts([
    'resources/js/vendor/*.js',
    'resources/js/security/*.js'
], 'public/js/security.js');

any 5.0.6 to fix ?