Laravel-mix: Enabling versioning breaks building

Created on 17 Apr 2018  路  7Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 2.1.1
  • Node Version: v9.11.1
  • NPM Version: 5.6.0
  • OS: MacOS High Sierra v10.13.4

Description:

I have the following in my webpack.mix.js:

mix
  .js('assets/js/front-scripts.js', 'assets/dist/')
  .js('assets/js/admin-scripts.js', 'assets/dist/')

  .sass('assets/scss/style.scss', 'assets/dist/')
  .sass('assets/scss/admin.scss', 'assets/dist/')

  .options({
    processCssUrls: false
  }).version();

If I remove .version() from the end everything compiles just fine. But in trying to add versioning, I get the following:

> [email protected] production /Users/jason/Sites/wpe-starter/wp-content/themes/custom
> NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                        

 DONE  Compiled successfully in 5461ms                                                                                                                                                           11:15:30 AM

fs.js:660
  return binding.open(pathModule.toNamespacedPath(path),
                 ^

Error: ENOENT: no such file or directory, open '/assets/dist/admin-scripts.js'
    at Object.fs.openSync (fs.js:660:18)
    at Object.fs.readFileSync (fs.js:565:33)
    at File.read (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/File.js:163:19)
    at File.version (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/File.js:172:25)
    at Manifest.hash (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/Manifest.js:52:65)
    at manifest.forEach.file (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:76:47)
    at Array.forEach (<anonymous>)
    at CustomTasksPlugin.applyVersioning (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:76:18)
    at Compiler.compiler.plugin.stats (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:12:22)
    at Compiler.applyPlugins (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/tapable/lib/Tapable.js:61:14)
    at emitRecords.err (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:264:11)
    at Compiler.emitRecords (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:371:38)
    at emitAssets.err (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:258:10)
    at applyPluginsAsyncSeries1.err (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:364:12)
    at next (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:361:9)
    at require.forEach.err (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/lib/Compiler.js:350:15)
    at /Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/node_modules/async/dist/async.js:1050:13)
    at /Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/webpack/node_modules/async/dist/async.js:958:16
    at /Users/jason/Sites/wpe-starter/wp-content/themes/custom/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:153:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] production: `NODE_ENV=production node_modules/webpack/bin/webpack.js --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] 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/jason/.npm/_logs/2018-04-17T18_15_30_266Z-debug.log

Steps To Reproduce:

This is a pretty clean and simple setup as it's a boilerplate. The files exist and compile fine without adding versioning. Feel free to grab the repo and try it out.

If there's anything more I can provide please let me know!

Thank you! Love Laravel Mix!

stale

Most helpful comment

I've got a similar error when running npm run prod inside docker container.

I was able to fix it using simple config update (set in webpack.mix.js):

mix.config.publicPath = 'public'

Update

Mine problem had a different reason. During docker build, I was not copying artisan file which made laravel-mix to assume that it's not running inside Laravel app.

Yet, the error I was receiving is basically the same as in the issues opening description.

All 7 comments

I got this error like you when i run ''npm run hot" sadly.

fs.js:660
  return binding.open(pathModule.toNamespacedPath(path),
                 ^
Error: ENOENT: no such file or directory, open '/Users/jeff/Code/wx.hezon/public/1.e6bc1b39b46cd0625392.hot-update.js'
    at Object.fs.openSync (fs.js:660:18)
    at Object.fs.readFileSync (fs.js:565:33)
    at File.read (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/File.js:163:19)
    at File.version (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/File.js:172:25)
    at Manifest.hash (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/Manifest.js:52:65)
    at manifest.forEach.file (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:76:47)
    at Array.forEach (<anonymous>)
    at CustomTasksPlugin.applyVersioning (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:76:18)
    at Compiler.compiler.plugin.stats (/Users/jeff/Code/wx.hezon/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:12:22)
    at Compiler.applyPlugins (/Users/jeff/Code/wx.hezon/node_modules/tapable/lib/Tapable.js:61:14)
    at Watching._done (/Users/jeff/Code/wx.hezon/node_modules/webpack/lib/Compiler.js:105:17)
    at compiler.emitRecords.err (/Users/jeff/Code/wx.hezon/node_modules/webpack/lib/Compiler.js:79:19)
    at Compiler.emitRecords (/Users/jeff/Code/wx.hezon/node_modules/webpack/lib/Compiler.js:371:38)
    at compiler.emitAssets.err (/Users/jeff/Code/wx.hezon/node_modules/webpack/lib/Compiler.js:62:20)
    at applyPluginsAsyncSeries1.err (/Users/jeff/Code/wx.hezon/node_modules/webpack/lib/Compiler.js:364:12)
    at next (/Users/jeff/Code/wx.hezon/node_modules/tapable/lib/Tapable.js:218:11)
// webpack.mix.js
// Version does not work in HMR mode
if (process.env.npm_lifecycle_event !== 'hot') {
  mix.version()
}

I've got a similar error when running npm run prod inside docker container.

I was able to fix it using simple config update (set in webpack.mix.js):

mix.config.publicPath = 'public'

Update

Mine problem had a different reason. During docker build, I was not copying artisan file which made laravel-mix to assume that it's not running inside Laravel app.

Yet, the error I was receiving is basically the same as in the issues opening description.

@ankurk91 To be clear, for me the issue is happening no matter how I try to compile: npm run dev and npm run watch fail for me as well. It's not just in hot mode.

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.

@JeffreyWay Please reopen this. As far as I know this issue still remains.

I'd prefer that someone create a new issue that provides the minimal number of steps to reproduce the issue using the latest version of Mix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

nezaboravi picture nezaboravi  路  3Comments

sdebacker picture sdebacker  路  3Comments

mementoneli picture mementoneli  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments