Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn run hot "ENOENT: no such file or directory" #1176

Closed
ellisio opened this issue Sep 7, 2017 · 4 comments
Closed

yarn run hot "ENOENT: no such file or directory" #1176

ellisio opened this issue Sep 7, 2017 · 4 comments

Comments

@ellisio
Copy link

ellisio commented Sep 7, 2017

  • Laravel Mix Version: 1.4.2
  • Node Version: v8.4.0
  • NPM Version: 5.4.1
  • OS: macOS 10.12.6

Description:

When running yarn run hot I get the following error. I have verified permissions on the public directory being 0755 since this is a local development environment. It appears that the HMR is not compiling those assets and pushing them into place as that file indeed does not exist.

$ yarn run hot
yarn run v1.0.1
$ 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


 DONE  Compiled successfully in 7567ms                                                                                                                                                                                                                        11:40:12 AM

fs.js:652
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/andrew/Developer/GitHub/CallLoop/TextLoop/public/js/vendor.js'
    at Object.fs.openSync (fs.js:652:18)
    at Object.fs.readFileSync (fs.js:553:33)
    at File.read (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/File.js:180:19)
    at File.version (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/File.js:190:25)
    at Manifest.hash (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/Manifest.js:55:65)
    at manifest.forEach.file (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:47)
    at Array.forEach (<anonymous>)
    at CustomTasksPlugin.applyVersioning (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:79:18)
    at Compiler.compiler.plugin.stats (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:12:22)
    at Compiler.applyPlugins (/Users/andrew/Developer/GitHub/CallLoop/TextLoop/node_modules/tapable/lib/Tapable.js:61:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

My webpack.mix.js contains:

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

if (process.env.NODE_ENV === 'production') {
    mix.disableNotifications();
}

mix.webpackConfig({
       devtool: 'source-map'
   })
   .autoload({
       jquery: ['$', 'window.jQuery', 'jQuery', 'jquery'],
       'popper.js/dist/umd/popper.js': ['Popper']
   })
   .js('resources/assets/js/app.js', 'public/js')
   .extract([
       // Bootstrap/jQuery
       'jquery',
       'jquery.payment',
       'jquery.phone',
       'popper.js',
       'bootstrap',

       // Vendors
       'axios',
       'babel-polyfill',
       'es6-promise',
       'lodash',
       'moment',
       'moment-timezone',

       // Vue
       'vue',
       'vuex',
       'vue-router',
   ])
   .sass('resources/assets/sass/app.scss', 'public/css')
   .version();
@ellisio
Copy link
Author

ellisio commented Sep 7, 2017

This appears to be caused by the mix.version() at the end. If I add NODE_HOT=true to the hot command in package.json. Then change mix.version() to the following HMR works.

if (!process.env.NODE_HOT) {
    mix.version();
}

Is there a native way to detect if running in HMR so I don't have to add the extra ENVVAR?

@oaklees
Copy link

oaklees commented Sep 12, 2017

Thank you for this, worked a charm.

@ankurk91
Copy link
Contributor

// Version does not work in HMR mode
if (process.env.npm_lifecycle_event !== 'hot') {
  mix.version()
}

@ServiceBoxGroupLimited
Copy link

Needed this on an old project thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants