简体   繁体   中英

npm run watch stops compiling after compiling once (laravel 8 homestead + Vue)

When I use npm run watch it compiles my changes and the pages get updated and when I make another edit it also compiles this. However, after that first edit, it will just stop updating my page. I don't get any errors. When I quit it and run npm run watch again it will again compile those changes so I don't think it's the code I'm editing that's causing it.

Things I've tried:

  • npm run watch-poll
  • npm run watch hot
  • mix.browserSync

This is my mix file:

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

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
    .vue()
    .sass('resources/sass/app.scss', 'public/css');

And this is my package.json:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "axios": "^0.21.1",
        "bootstrap": "^4.0.0",
        "browser-sync": "^2.26.14",
        "browser-sync-webpack-plugin": "^2.3.0",
        "jquery": "^3.2",
        "laravel-mix": "^6.0.16",
        "lodash": "^4.17.19",
        "popper.js": "^1.12",
        "postcss": "^8.1.14",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.20.1",
        "sass-loader": "^8.0.0",
        "vue": "^2.5.17",
        "vue-loader": "^15.9.5",
        "vue-template-compiler": "^2.6.10"
    },
    "dependencies": {
        "vue-axios": "^3.2.4",
        "vue-router": "^3.5.1"
    }
}

I had the same problem and tried absolutely everything. Eventually I found that the issue was with how I import the routes.

{
    path: '/test',
    name: 'test',
    component: () => import("../views/pages/test.vue")
},

I forgot to use a capital letter.

component: () => import("../views/pages/test.vue")

Should be:

component: () => import("../views/pages/Test.vue")

Apparantly when I run 'npm run watch' laravel mix is fine with importing my Test.vue eventhough I wrote 'test.vue'. However, after the initial start laravel mix uses dynamic loading and at that point it will ignore the changes if I do not use the capital letter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM