unocss: Nuxt 3.9.0 Internal server error: Soft-invalidated module "entry.js" should not have existing transform result

UnoCSS version

0.58.2

Describe the bug

After running nuxt dev server, go to browser and refresh the page once, the error will show up.

Internal server error: Soft-invalidated module "/node_modules/nuxt/dist/app/entry.js" should not have existing transform result

Reproduction

  1. create a new nuxt project
  2. add @unocss/nuxt module
  3. run nuxt dev
  4. go to browser, no error on first load
  5. (Require this step) refresh the page once and the error shows up

https://stackblitz.com/edit/github-xtxzaj?file=package.json

Additional info

Already try to add the following config regarding to https://github.com/unocss/unocss/issues/3468#issuecomment-1871049463 but still having error

export default defineConfig({
  features: {
    inlineStyles: false,
  },
})

System Info

"nuxt": "^3.9.0",
"vue": "^3.4.0",
"vue-router": "^4.2.5"

Validations

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Reactions: 37
  • Comments: 31 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Alright, hopefully https://github.com/vitejs/vite/pull/15768 should fix this

After upgrading to Nuxt 3.9.3 everything is working fine for me.

Again, I would need a minimal reproduction to investigate this - saying +1 does not improve the situation, for the record. Thanks

Any news on this?

I do indeed have the same issue but it kinda disappears after a few refreshes? Not really consistent but not a huge blocker either. 🤔

https://stackblitz.com/edit/github-dqvhqs?file=package.json This link provides the minimal reproduction. To reproduce the warning, please follow these steps:

  1. Wait for the Nuxt build to complete.
  2. Once the page has finished loading, click refresh once.

unocss 5.8.3 nuxt 3.9.3 vue 3.3.13 vue-router latest Internal server error: Soft-invalidated module "/node_modules/.pnpm/nuxt@3.9.3_eslint@8.56.0_rollup@4.9.5_sass@1.70.0_typescript@5.3.3_vite@5.0.12/node_modules/nuxt/dist/app/entry.js" should not have existing transform result

Just tested and this issue should be fixed since vite v5.1.0 (nuxt v3.10.2). Related commits: https://github.com/vitejs/vite/pull/15768, https://github.com/vitejs/vite/pull/15785

Thank you @antfu, @bluwy 🍻

It’s probably introduced in https://github.com/vitejs/vite/pull/14654, not yet sure how to fix it, investigating

Already update the reproduction link with the latest UnoCSS version 0.58.4 and the error still shows up. https://stackblitz.com/edit/github-xtxzaj?file=package.json

"@unocss/nuxt": "^0.58.4",
"nuxt": "^3.9.0",
"vue": "^3.4.0",
"vue-router": "^4.2.5"

Steps

  1. go to browser and wait for loading complete, there’s no error on first load
  2. (Require this step) refresh the page once and the error shows up

https://github.com/unocss/unocss/assets/44749100/e11d8894-a835-42d2-9b07-28b3135a6c3b

Again, I would need a minimal reproduction to investigate this - saying +1 does not improve the situation, for the record. Thanks

You can use any one reproduction from above and test it like just refresh the page in browser. I think its not working on stackblitz or any sandboxes, you need start it on local environment

Hmm I am still seeing the bug in the latest release, version ^0.58.4. The issue arises during the initial startup but is resolved upon refreshing the page… Although its hard to replicate, after that first initial issue, I can’t seem to get it to reappear when I start/stop the dev sever again.

Actually I have to wait about 30sec to a min after stopping/starting the dev sever for it to reappear. Here is a screenshot from just right now: Screenshot 2024-01-25 at 10 40 31 AM

Hmm could this have anything to do with using @unocss/transformer-directives within a sass scoped context? I have some styling on my Nuxt components like this:

<style lang="scss" scoped>
form {
  @apply flex flex-col my-6;

  .container {
    @apply relative w-full;

    input {
      @apply w-full py-2 px-3.5 mb-2.5;
      @apply normal-case border border-zinc-300 rounded-md appearance-none;
    }
  }
}
</style>

unocss 5.8.3 @unocss/nuxt 0.58.3 nuxt 3.9.3 vue 3.4.15 image

+1, I have temporarily downgraded nuxt to version 3.8.2.

Maybe it is also depending on the OS of the user. In my case Linux (Ubuntu) works worse than MacOS hence it’s a bit tricky to reproduce properly on MacOS.

link

I downloaded code from stackblitz. link above

I’m not coding nuxt, but I tried debug error after I read on Twitter =))) I recorded an error in this link, everybody can check: https://streamable.com/hvrvnw

Step: 1: npm run dev open localhost at the first browser 2: turn off npm run dev 3: remove .nuxt and node_modules/.cache 4: open 2nd browser 5: npm run dev and open localhost at 2nd browser => The error will appear on the first browser

TL;DR put this in your Nuxt config:

export default defineConfig({
  features: {
    inlineStyles: false,
  },
})

Original answer

The error still appears despite this

Putting this in my Nuxt config worked in my scenario:

export default defineConfig({
  features: {
    inlineStyles: false,
  },
})

Original answer