davestewart / nuxt-content-assets

Enable locally-located assets in Nuxt Content

Home Page:https://npmjs.com/package/nuxt-content-assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nitro Build gets stuck at "You can preview this build using node .output/server/index.mjs" and doesn't complete when using nuxt-content-assets

brunopbarbosa opened this issue Β· comments

Background

Using this module to serve relative images with nuxt content, runs as expected while in dev.

Issue

When running npm run build (both on server or local) with the module enabled on the nuxt.config file, the build goes all the way through until this point and then just hangs indefinitely.

removing this module from the module list in the config file seems to let the build run as normal.

Any insight would be highly appreciated!

Hello,

Sorry to leave you hanging! (EDIT: literally πŸ˜†)

What version of Nuxt are you running (run the code below to find out) ?

echo -e "\nNode `node -v`\n" && npm list nuxt @nuxt/content nuxt-content-assets --depth=0

If > 3.6.5 it could be related to this:

Can you confirm?

See also the linked issue 169. Right now it seems a few modules are causing this, the cause is not yet known, but I suspect it's something to do with Nuxt > 3.7.0.

Run into this problem myself under windows.
Fixing the nuxt version to 3.6.5 fixed it, it does appear to be a 3.7 issue

Hi, yes, i downgraded to 3.6.5 and it does in fact solve it!

I'll be keeping an eye out on those other issues you mentioned, at the moment fixing on 3.6.5 is not problematic.

And thanks again for your help! I didn't have to hang for too long πŸ˜†

I'll leave the issue open in case someone else ends up here, but feel free to close it if you think it's more appropriate!

Whoop!

Yes, let's leave it open until it – hopefully – gets solved upstream.

Thanks for reporting back!

This issue is now being tracked in the Nuxt CLI repo:

I think I've found a temporary workaround that allows us to use the latest version of nuxt with this module
Based on these links

I tried adding the following to the nuxt config

export default defineNuxtConfig({
  hooks: {
    close: (nuxt) => {
      if (!nuxt.options._prepare)
        process.exit()
    }
  }
})

Then I run nuxi generate and it all seems to work / finish under nuxt 3.8.1
not ideal but at least I think we can use the latest nuxt until there's a better fix

@Hecatron that resolves the issue but is there any downside using it?

I don't think so but I can't be 100% certain, for now it's a sort of temporary fix until nuxt sort they're end out, since I think it's not the only module it affects

I'm not sure if related / useful but one potential downside to the workaround is I had to add an env check in order to keep Vitest working with @nuxt/test-utils

nuxt.config.{js|ts}

export default defineNuxtConfig({
  hooks: {
    close: (nuxt) => {
+     const isTesting = process.env.NODE_ENV === 'test'
+     if (!nuxt.options._prepare && !isTesting) {
         process.exit()
    }
  }
})

package.json

"scripts": {
+  "test": "NODE_ENV=test && vitest"
 }

This stops Vitest outputting nothing to the console.

Also noticed this message when running Vitest.

[Content Assets] Your browser does not support WebSocket

PS absolutely adore this module thank you for making it πŸ™

I'm also facing the issue of where I use yarn install gets stuck at "βœ” Types generated in .nuxt "

with the temporary solution of "hooks" in nuxt.config.ts seems to fix for yarn build, but for yarn install its still there.

I have following versions:

β”œβ”€β”€ @nuxt/content@2.12.1
β”œβ”€β”€ nuxt-content-assets@1.3.3
└── nuxt@3.7.4

The issue here, as explained in nuxt/cli#169 (comment), is that watchers were not being closed out.

I've made a couple of changes to close watchers gracefully when Nuxt exits, as well as avoiding starting some of them in the first place when not in development mode.

I hope this helps (#65). πŸ™