question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mix 5.0.5: Causing UnhandledPromiseRejectionWarning error

See original GitHub issue
  • 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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:27

github_iconTop GitHub Comments

4reactions
JeffreyWaycommented, Oct 8, 2020

Thank you. Fixed.

4reactions
fatihgunecommented, Sep 1, 2020

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');

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mix 5.0.5: Causing UnhandledPromiseRejectionWarning error
Description: Running npm run dev no longer works once Laravel mix is upgraded to 5.0.5. It's throwing an UnhandledPromiseRejectionWarning about ...
Read more >
npm - Laravel mix - UnhandledPromiseRejectionWarning: Error
css in the folder C:\xampp734\templatedocs is updated after I run the command but also with the error message. So, what is causing the...
Read more >
Release notes and release history for Mobiscroll
We fixed an issue with drag & drop on touch devices, where tapping on the event after dropping it on an invalid range...
Read more >
Trying Laravel Jetstream But Getting An Error On "Npm Run ...
Running npm run dev no longer works once Laravel mix is upgraded to 5.0.5.It's throwing an UnhandledPromiseRejectionWarning about.
Read more >
All Problems Tagged With Whatever - Code Grepper
... 'mix' is not recognized as an internal or external command, ... failed: socketexception: error connecting to 127.0.0.1:27017 :: caused by :: connection ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found