【问题标题】:npm run watch stops compiling after compiling once (laravel 8 homestead + Vue)npm run watch 编译一次后停止编译(laravel 8 homestead + Vue)
【发布时间】:2021-07-07 21:35:25
【问题描述】:

当我使用 npm run watch 时,它会编译我的更改并更新页面,当我进行另一个编辑时,它也会编译它。但是,在第一次编辑之后,它将停止更新我的页面。我没有收到任何错误。当我退出它并再次运行 npm run watch 时,它会再次编译这些更改,所以我认为不是我正在编辑的代码导致它。

我尝试过的事情:

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

这是我的混音文件:

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');

这是我的 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"
    }
}

【问题讨论】:

    标签: php node.js laravel vue.js npm


    【解决方案1】:

    我遇到了同样的问题,并且尝试了所有方法。最终我发现问题在于我如何导入路由。

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

    我忘记使用大写字母了。

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

    应该是:

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

    显然,当我运行“npm run watch”时,laravel mix 可以很好地导入我的 Test.vue,尽管我写了“test.vue”。但是,在初始启动 Laravel 混合使用动态加载之后,如果我不使用大写字母,它将忽略更改。

    【讨论】:

      猜你喜欢
      • 2018-07-06
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      相关资源
      最近更新 更多