I just started a fresh project and when I use the version() function I get this error telling me that no such file or directory, open '/dist/js/app.js' but as you can see in the image the files and the directory are present but if I remove the version() everything works fine.

âžœdanny: ~/Documents/Projects/my-app npm run watch
> [email protected] watch /Users/danny/Documents/Projects/my-app
> NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
10% building modules 1/1 modules 0 active
Webpack is watching the files…
95% emitting
DONE Compiled successfully in 12950ms 9:17:58 PM
fs.js:641
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/dist/js/app.js'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at File.read (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/File.js:180:19)
at File.version (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/File.js:190:25)
at Manifest.hash (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/Manifest.js:55:65)
at manifest.forEach.file (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:47)
at Array.forEach (native)
at CustomTasksPlugin.applyVersioning (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:18)
at Compiler.compiler.plugin.stats (/Users/danny/Documents/Projects/my-app/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:12:22)
at Compiler.applyPlugins (/Users/danny/Documents/Projects/my-app/node_modules/tapable/lib/Tapable.js:61:14)
at Watching._done (/Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:100:16)
at /Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:75:18
at Compiler.emitRecords (/Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:369:37)
at /Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:58:19
at /Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:362:11
at next (/Users/danny/Documents/Projects/my-app/node_modules/tapable/lib/Tapable.js:154:11)
at Compiler.compiler.plugin (/Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/Users/danny/Documents/Projects/my-app/node_modules/tapable/lib/Tapable.js:158:13)
at Compiler.afterEmit (/Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:359:8)
at Compiler.<anonymous> (/Users/danny/Documents/Projects/my-app/node_modules/webpack/lib/Compiler.js:354:14)
at /Users/danny/Documents/Projects/my-app/node_modules/async/dist/async.js:421:16
at iteratorCallback (/Users/danny/Documents/Projects/my-app/node_modules/async/dist/async.js:998:13)
at /Users/danny/Documents/Projects/my-app/node_modules/async/dist/async.js:906:16
at /Users/danny/Documents/Projects/my-app/node_modules/graceful-fs/graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "watch"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] watch: `NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script 'NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the laravel-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs laravel-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls laravel-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/danny/Documents/Projects/my-app/npm-debug.log
mkdir srctouch src/app.js src/app.scsswebpack.configmix.js('src/app.js', 'dist/js')
.sass('src/app.scss', 'dist/css')
.version();
NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.jsAdding mix.setPublicPath('./') at the top of your webpack.mix.js file fix the issue
@DannyFeliz You are a hero! I've been struggling with this error for hours and this fixed it!
Added mix.setPublicPath('./') to webpack.mix.js and now mix-manifest.json file not in ./public
@DannyFeliz Thank you!!!
@Leshgan I have the same problem
Most helpful comment
_Update_
Adding
mix.setPublicPath('./')at the top of your webpack.mix.js file fix the issue