I use version() when in Production mode
if (mix.inProduction()) {
mix.version();
}
And I need to copy one template:
mix.copy('./frontend/admin/dist/index.html', 'resources/views/admin.blade.php');
When I run npm run dev - it's ok.
But when npm run prod I got error
``` DONE Compiled successfully in 25411ms 22:34:42
fs.js:648
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/Users/aleksey/Documents/Sites/foodstory/public/resources/views/admin.blade.php'
at Object.fs.openSync (fs.js:648:18)
at Object.fs.readFileSync (fs.js:553:33)
at File.read (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/File.js:180:19)
at File.version (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/File.js:190:25)
at Manifest.hash (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/Manifest.js:55:65)
at manifest.forEach.file (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:47)
at Array.forEach (
at CustomTasksPlugin.applyVersioning (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:18)
at Compiler.compiler.plugin.stats (/Users/aleksey/Documents/Sites/foodstory/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:12:22)
at Compiler.applyPlugins (/Users/aleksey/Documents/Sites/foodstory/node_modules/tapable/lib/Tapable.js:61:14)
at emitRecords.err (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:264:11)
at Compiler.emitRecords (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:371:38)
at emitAssets.err (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:258:10)
at applyPluginsAsyncSeries1.err (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:364:12)
at next (/Users/aleksey/Documents/Sites/foodstory/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/Users/aleksey/Documents/Sites/foodstory/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:361:9)
at require.forEach.err (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/lib/Compiler.js:350:15)
at /Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/node_modules/async/dist/async.js:473:16
at iteratorCallback (/Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/node_modules/async/dist/async.js:1050:13)
at /Users/aleksey/Documents/Sites/foodstory/node_modules/webpack/node_modules/async/dist/async.js:958:16
at /Users/aleksey/Documents/Sites/foodstory/node_modules/graceful-fs/graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:137:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aleksey/.npm/_logs/2018-02-07T19_34_44_810Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: npm run production
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aleksey/.npm/_logs/2018-02-07T19_34_44_882Z-debug.log
```
If I comment code mix.version(); there are no errors
But if I comment only mix.copy('./frontend/admin/dist/index.html', 'resources/views/admin.blade.php'); there are no errors too!
Thus, I think mix.copy() somehow influences to version() function.
Issue #939 doesn't work for me.
Hi @Leshgan,
Looking through the API, the version implementation doesn't directly influence the copy method but more interesting is that the public path is being forced upon this to path only when version is used. That said, simply telling Mix where the root for the to path is should solve the issue.
mix.copy('./frontend/admin/dist/index.html', './resources/views/admin.blade.php');
This should prevent the error from occurring.
@cshawaus thanks for the answer, but this fix doesn't take any effect.
@Leshgan , I'm not sure if this helps, but I was running into a very similar issue. This fixed it for me.
let mix = require('laravel-mix');
mix.setPublicPath('_site');
mix.js('assets/js/script.js', '_site/assets/js')
.sass('assets/scss/main.scss', '_site/assets/css')
.version()
.setPublicPath(__dirname) // Reset the public path before copying
.copy('_site/mix-manifest.json', '_data/')
;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@Leshgan , I'm not sure if this helps, but I was running into a very similar issue. This fixed it for me.