question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run watch updates app.js twice, then compiles successfully without changing app.js when files change

See original GitHub issue
  • Laravel Mix Version: 6.0.10
  • Node Version (node -v): 15.5.1
  • NPM Version (npm -v): 7.3.0
  • OS: MacOS 11.2.3

Description: I’m using Mix, Docker, Sail, all right out of the box. Everything was working great, using npm run watch. Suddenly (as far as I know, I didn’t change anything relevant) it stopped working. Each time I run npm run watch it compiles successfully and updates app.js twice. The third time my files change, it says it compiled successfully, but app.js has not been modified. (I didn’t start counting how many times it updated successfully at first, so I’m not totally certain it’s always 2 times, not 3, but since I’ve been counting it’s always 2.) I tried restarting my computer without effect. npm run watch-poll seems to have the same problem.

Steps To Reproduce:

I haven’t tried creating a new project to see if it has the same problem.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:22

github_iconTop GitHub Comments

3reactions
ghostcommented, Jul 20, 2021

I had the same problem and tried absolutely everything. Eventually I found that the issue was with how I imported the Vue 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’. Thats why I did see changes when I restarted the watch. 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.

Watch will also ignore changes in components, after first run, if you import it without the correct use of capital or lowercase letters.

import Button from '@/components/Button'

I thought I’d post my mistake. Maybe some of you have the same issue?

0reactions
trevormilescommented, Sep 10, 2022

What fixed it for me was similar to what @ghost mentioned.

I had an Index.vue file inside of a folder called EnrollForm, which I was importing like so:

import EnrollForm from '../../EnrollForm'

When I started up npm run watch, my changes were correctly reflected in the browser only for two compiles, and then the compiler would say “Build successful” but my changes were not reflected in the browser.

Per @ghost’s comment, I tried changing the import statement to this:

import EnrollForm from '../../EnrollForm/Index.vue'

And then my changes began to be reflected in the browser every time the compiler ran 🤷‍♂️

Thanks @ghost!

Read more comments on GitHub >

github_iconTop Results From Across the Web

run watch updates app.js twice, then compiles successfully ...
Each time I run npm run watch it compiles successfully and updates app.js twice. The third time my files change, it says it...
Read more >
Gulp.js, watch task runs twice when saving files - Stack Overflow
The problem is occurring because your editor, in this case Coda 2, is modifying the file twice on save. The same problem occurs...
Read more >
laravel-mix - Bountysource
Each time I run npm run watch it compiles successfully and updates app.js twice. The third time my files change, it says it...
Read more >
Chapter 1, Writing Your First JavaScript Program - O'Reilly
Compiling is the process of creating a file that will run on a computer by translating the code a programmer writes into instructions...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
Node.js, the cross-platform runtime environment, has seen its fair share of praise and criticism for what it offers to developers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found