Cannot read property 'hmr' of undefined
See original GitHub issue- Laravel Mix Version: 6.0.5 (
npm list --depth=0
) - Node Version : v14.15.3
- NPM Version : 6.14.9
- OS: Widows 10 Pro /64bit
Description:
I started getting it after updating dependencies with this problem. When I run the “npx run watch or npx mix watch” command, I get the following error.
[webpack-cli] TypeError: Cannot read property 'hmr' of undefined
at Object.<anonymous> (C:\vue-project\x-tools\webpack.mix.js:59:26)
at Module._compile (C:\vue-project\x-tools\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (C:\vue-project\x-tools\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at module.exports (C:\vue-project\x-tools\node_modules\laravel-mix\setup\webpack.config.js:3:5)
at C:\vue-project\x-tools\node_modules\webpack-cli\lib\webpack-cli.js:720:43
at Array.map (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ watch: `mix watch`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ watch 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! C:\Users\pcm\AppData\Roaming\npm-cache\_logs\2020-12-29T06_59_32_296Z-debug.log
Steps To Reproduce:
This is my current webpackConfig content.
const path = require('path')
const fs = require('fs-extra')
const mix = require('laravel-mix')
require('laravel-mix-versionhash')
const tailwindcss = require('tailwindcss')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
mix
.js('resources/js/app.js', 'public/dist/js')
.options({
processCssUrls: false,
postCss: [tailwindcss('./tailwind.config.js')]
}).postCss('resources/sass/app.css', 'public/dist', [require('tailwindcss')])
if (mix.inProduction()) {
mix
.versionHash()
} else {
mix.sourceMaps()
}
mix.webpackConfig({
mode: "development",
devtool: "inline-source-map",
devServer: {
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*'
},
host: "web",
port: 80
},
plugins: [
new CleanWebpackPlugin()
],
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'@': path.join(__dirname, './resources/js')
}
},
output: {
chunkFilename: 'dist/js/[chunkhash].js',
path: mix.config.hmr ? '/' : path.resolve(__dirname, './public/build')
}
})
mix.then(() => {
if (!mix.config.hmr) {
process.nextTick(() => publishAseets())
}
})
function publishAseets() {
const publicDir = path.resolve(__dirname, './public')
if (mix.inProduction()) {
fs.removeSync(path.join(publicDir, 'dist'))
}
fs.copySync(path.join(publicDir, 'build', 'dist'), path.join(publicDir, 'dist'))
fs.removeSync(path.join(publicDir, 'build'))
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Cannot read property 'hmr' of undefined · Issue #2718 - GitHub
When I run the "npx run watch or npx mix watch" command, I get the following error. [webpack-cli] TypeError: Cannot read property 'hmr'...
Read more >Webpack 5 HMR issue - Cannot read property ...
First time it compiles properly, but when it comes to recompiling after code changes - it breaks with HookWebpackError: Cannot read property ' ......
Read more >Laravel HMR error - Laracasts
... an error in the browser's console that says Uncaught TypeError: Cannot read property 'call' of undefined my environement : host is windows...
Read more >laravel-mix - Bountysource
[webpack-cli] TypeError: Cannot read property 'hmr' of undefined at Object.<anonymous> (C:\vue-project\x-tools\webpack.mix.js:59:26) at Module.
Read more >Hot Module Replacement - webpack
This feature is great for productivity. All we need to do is update our webpack-dev-server configuration, and use webpack's built-in HMR plugin. We'll...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
to
before
path: mix.config.hmr ? '/' : path.resolve(__dirname, './public/build')
after
path: path.resolve(__dirname, './public/build')
OU Alguém conseguiu resolver isso daí??? Smbdy solve this?