poashoas
poashoas

Reputation: 1894

Laravel mix - UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory

I think I have an install problem somewhere. I have updated to the latest node and npm, I did npm install in my root dir. When I do "npm run dev" it cannot find 'C:\public\css\site.css'. Well, it's right! But it doesn't supposed to look for a file at that place. The file site.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 message?

My webpack.mix.js

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

mix.js('resources/js/bootstrap.js', 'public/libs/bootstrap/js')
    .js('resources/js/mobilenav.js', 'public/js')
    .js('resources/js/pixieLib.js', 'public/js')
    .js('resources/js/rangeslider.js', 'public/js')
    .js('resources/js/site.js', 'public/js')
    
    .sass('resources/sass/bootstrap.scss', 'public/libs/bootstrap/css')
    .sass('resources/sass/site.scss', 'public/css')
    
    .copyDirectory('node_modules/@glidejs/glide/dist', 'public/plugins/glide')
    .version();

My package.json

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "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 --disable-host-check --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 --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.19",
    "cross-env": "^7.0",
    "laravel-mix": "^5.0.1",
    "lodash": "^4.17.19",
    "postcss": "8.1",
    "resolve-url-loader": "^3.1.0",
    "sass": "^1.15.2",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.12"
  },
  "dependencies": {
    "@glidejs/glide": "^3.4.1",
    "bootstrap": "^4.3.1",
    "bootstrap.native": "^3.0.14",
    "diff-match-patch": "^1.0.5",
    "node-sass": "^4.14.1",
    "popper.js": "^1.16.1"
  }
}

My command-line

C:\xampp734\templatedocs>npm run dev

dev npm run development

development cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js

98% after emitting SizeLimitsPlugin

DONE Compiled successfully in 53404ms 9:24:47 PM

(node:4412) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\public\css\site.css' at Object.openSync (fs.js:476:3) at Object.readFileSync (fs.js:377:35) at File.read (C:\xampp734\templatedocs\node_modules\laravel-mix\src\File.js:166:19) at File.version (C:\xampp734\templatedocs\node_modules\laravel-mix\src\File.js:173:25) at Manifest.hash (C:\xampp734\templatedocs\node_modules\laravel-mix\src\Manifest.js:52:65) at C:\xampp734\templatedocs\node_modules\laravel-mix\src\webpackPlugins\CustomTasksPlugin.js:96:26 at Collection.each (C:\xampp734\templatedocs\node_modules\collect.js\dist\methods\each.js:21:14) at CustomTasksPlugin.applyVersioning (C:\xampp734\templatedocs\node_modules\laravel-mix\src\webpackPlugins\CustomTasksPlugin.js:95:37) at C:\xampp734\templatedocs\node_modules\laravel-mix\src\webpackPlugins\CustomTasksPlugin.js:16:30 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) (Use node --trace-warnings ... to show where the warning was created) (node:4412) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)

Upvotes: 1

Views: 1897

Answers (1)

A. Joahny
A. Joahny

Reputation: 310

I had the same problem. When we use laravel mix without laravel we have to set a public path :

mix.setPublicPath('public');

source : https://laravel-mix.com/docs/6.0/faq#does-this-tool-require-that-i-use-laravel

Upvotes: 2

Related Questions