cli
cli copied to clipboard
nuxi `prepare` or `build` hangs
Environment
- Operating System: Darwin
- Node Version: v20.5.1
- Nuxt Version: 3.7.0
- CLI Version: 3.7.0
- Nitro Version: 2.6.1
- Package Manager: [email protected]
- Builder: -
- User Config: experimental, css, ssr, nitro, app, modules, devtools
- Runtime Modules: @pinia/[email protected], @nuxt/[email protected], @vueuse/[email protected], @vuestic/[email protected]
- Build Modules: -
Reproduction
https://stackblitz.com/edit/github-khexbq?file=package.json
Describe the bug
Doing a npm install stucks at the above position , doing a npx nuxi upgrade --force fixes the issue, Conflicting during deploying .
Additional context
No response
### Logs
+ npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @scaleflex/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN react@"18.2.0" from [email protected]
npm WARN node_modules/filerobot-image-editor
npm WARN filerobot-image-editor@"^4.5.1" from the root project
npm WARN 12 more (react-konva, styled-components, its-fine, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/icons
npm WARN @scaleflex/icons@"^1.0.0-beta.99" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN 1 more (react-filerobot-image-editor)
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN peer react@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/icons
npm WARN @scaleflex/icons@"^1.0.0-beta.99" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN 1 more (react-filerobot-image-editor)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @scaleflex/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react-dom
npm WARN react-dom@"18.2.0" from [email protected]
npm WARN node_modules/filerobot-image-editor
npm WARN filerobot-image-editor@"^4.5.1" from the root project
npm WARN 5 more (react-konva, styled-components, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react-dom@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/icons
npm WARN @scaleflex/icons@"^1.0.0-beta.99" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN 1 more (react-filerobot-image-editor)
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react-dom
npm WARN peer react-dom@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/icons
npm WARN @scaleflex/icons@"^1.0.0-beta.99" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN 1 more (react-filerobot-image-editor)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @scaleflex/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN react@"18.2.0" from [email protected]
npm WARN node_modules/filerobot-image-editor
npm WARN filerobot-image-editor@"^4.5.1" from the root project
npm WARN 12 more (react-konva, styled-components, its-fine, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN @scaleflex/ui@"1.0.0-beta.99" from [email protected]
npm WARN node_modules/react-filerobot-image-editor
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN peer react@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN @scaleflex/ui@"1.0.0-beta.99" from [email protected]
npm WARN node_modules/react-filerobot-image-editor
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @scaleflex/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react-dom
npm WARN react-dom@"18.2.0" from [email protected]
npm WARN node_modules/filerobot-image-editor
npm WARN filerobot-image-editor@"^4.5.1" from the root project
npm WARN 5 more (react-konva, styled-components, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react-dom@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN @scaleflex/ui@"1.0.0-beta.99" from [email protected]
npm WARN node_modules/react-filerobot-image-editor
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react-dom
npm WARN peer react-dom@"^16.13.1" from @scaleflex/[email protected]
npm WARN node_modules/@scaleflex/ui
npm WARN @scaleflex/ui@"1.0.0-beta.99" from [email protected]
npm WARN node_modules/react-filerobot-image-editor
> [email protected] postinstall
> nuxt prepare
[warn] Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.
[success] Types generated in .nuxt
@danielroe I Guess this is only happening when preset is static ,
Checked on Windows / MaC .
- [ ]
Update : Found out it was unable to build '@vuestic/nuxt', removing it from nuxt.config.ts made the terminal to conttinue to start server, but the issue is not fixed,
it was working well in nuxt 3.5.2 release.
I have the same problem but I'm not using @vuestic/nuxt. It's stuck on:
postinstall
nuxt prepare
[success] Types generated in .nuxt
This is caused by vuestic/nuxt registering a watcher, without signalling it to close. I've opened https://github.com/epicmaxco/vuestic-ui/pull/3748 to fix that.
@pi0, I think we should probably still exit nuxi even if watchers are still around - can you think what might be causing this?
@danielroe I also have the same problem but I'm not using vuestic. Some core libs like nuxt/content, nuxt/image-edge, fontaine etc. The only third party package is 'nuxt-content-assets'. Please let me know if you want me to create a separate issue for that.
same problem with static used for some pages
Had the same issue; removing the 'nuxt-content-assets' module resolved it.
Same issue and I am not using vuestic/nuxt or nuxt-content-assets
(edit) I realized that removing the module nuxt-mongoose resolves this issue but I don't know if is a problem of the module or how I implement it.
Happens for me too when prerendering any route (even /sitemap.xml) when the app uses @nuxt/image. Other apps that dont use @nuxt/image can prerender fine.
It looks like this problems can be caused by many libraries like vuestic, nuxt-content-assets and @nuxt/image. I'm prerendering sitemap in my project so it may be connected.
Also in nuxt-vitest latest update (owing to cli update). Was resolved when downgrading cli to 3.7.3.
see https://github.com/danielroe/nuxt-vitest/pull/324
I am not sure if the main issue of nuxt prepare is the same as other reports here in this issue and would really appreciate if anyone else facing similar hanging problem, use a new issue with a working reproduction.
For last issue with nuxt-vitest and dev command, passing nuxt dev --no-fork fixed the issue.
- https://github.com/danielroe/nuxt-vitest/pull/335
- https://github.com/nuxt/cli/pull/174
Nuxt Content Assets author here.
Happy to help if possible, but Nuxt development moves so quickly, I'm not sure I can.
@pi0 - any advice on where to look in my module?
For the time being, I'll upgrade to Nuxt 2.8 in the module demo folder, and will create a new issue with the demo folder being the reproduction if it happens there.
A note from https://github.com/nuxt/nuxt/issues/23334, nitro pre-renderer does not calls close hook it seems to allow authors properly close instances (need to investigate more).
using workaround given by @pi0 here : https://github.com/nuxt/nuxt/issues/23334#issuecomment-1752170942
This workaround has nasty side effect: 1- nuxt prepare doesn't generate ts.config files in ./.nuxt folder 2- nuxt-vitest stop working properly
Occurring for me when running bun run build and pre-rendering anything using any of the methods, i.e. an array of routes in nitro.prerender.routes or using just nitro.static: true ... bun run generate and bun run build --prerender both also hang.
If I remove that configuration, I can use bun run build successfully
Using ps-tree thinking maybe I've a rogue child process, I'm seeing two esbuild child processes (and the ps command from ps-tree):
✔ You can preview this build using npx serve .output/public nitro 12:21:35 AM
Child processes: [ { parent_process_id: '59355', 12:21:35 AM
process_id: '59363',
command:
'@/node_modules/.pnpm/registry.npmjs.org+@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild' },
{ parent_process_id: '59355',
process_id: '59365',
command:
'@/node_modules/.pnpm/registry.npmjs.org+@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild' },
{ parent_process_id: '59355', process_id: '59434', command: 'ps' } ]
This is what I added to the close hook, maybe it will help someone else:
import pstree from "ps-tree"
export default defineNuxtConfig({
hooks: {
"close": () => {
pstree(process.pid, (err, children) => {
if (err) {
console.error(err)
return
}
console.log("Child processes:", children.map(p => (
{
parent_process_id: p.PPID,
process_id: p.PID,
command: p.COMM.replace(__dirname, "@")
}
)
))
})
}
},
})
Would it make sense add something like this to the Nuxt codebase itself?
This seems like it might possibly be relevant: https://github.com/evanw/esbuild/issues/985#issuecomment-1718768339
This is almost certainly because of this: https://github.com/evanw/esbuild/issues/2727#issuecomment-1343153719
As, with the pstree command (brew install pstree) we see the --ping argument:
\-+= 09637 larry ~/Applications/WebStorm.app/Contents/MacOS/webstorm
\-+= 00289 larry /bin/zsh --login -i
\-+= 69336 larry bun run build
\-+- 69337 larry node <redacted>/l422y/app/node_modules/.bin/../nuxt/bin/nuxt.mjs build
|--- 69348 larry <redacted>/l422y/app/node_modules/.pnpm/registry.npmjs.org+@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild --service=0.19.5 --ping
|--- 69349 larry <redacted>/l422y/app/node_modules/.pnpm/registry.npmjs.org+@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild --service=0.18.20 --ping
\-+- 69392 larry pstree -p 69337
\--- 69393 root ps -axwwo user,pid,ppid,pgid,command
hm... even if i have node kill these, the process is not closing. which seems to suggest it's something internal like a promise that is not resolving..
When prerendering and using node-cron, build hangs
import cron from 'node-cron'
export default defineNitroPlugin(async () => {
startCron()
})
function startCron() {
cron.schedule('0 4 * * *', async () => {
console.warn('Running scheduled task')
})
console.warn('Cron started'
Is there a way to detect if the environment is running for pre-rendering? That way we can skip things like cron when pre-rendering and avoid problems like that.
@unitythemaker You can use process.static or import.meta.prerender static flags.
@unitythemaker You can use
process.staticorimport.meta.prerenderstatic flags.
Neither of those work out of the box within the nuxt close hook. process.static has a type error (easily ignoreable) and the other cant be used outside of a module.
any progress on this? my npm run build hangs on this line
✔ You can preview this build using node .output/server/index.mjs nitro
im not using any of these 3 libraries vuestic, nuxt-content-assets and @nuxt/image
check if any module or plugin you're using has a setTimeout in it, i had one that was, i was able to remove it from the library and it didn't hang anymore
We got the same issue and wasn't able to find the module or plugin that made our build process hang. It started happening after updating Nuxt and packages. Only esbuild was still running. We tried killing esbuild on close hook, but no luck.
It's hacky, but we ended up just exiting the process on close-hook. Nut sure if this is bad or not, but it made our application build again with no apparent issues. 😸
hooks: {
close: (nuxt) => {
if (!nuxt.options._prepare) {
process.exit();
}
},
},
I'm running nuxi build on a Nuxt-Brigde project.
Also hanging on: ✔ You can preview this build using node .output/server/index.mjs
nuxt prepare just started hanging for me and I'm not sure why. I think it might be due to execSync commands in the 'build:before' hook but this wasn't causing an issue before. 🤔
I got this to work by doing the opposite of what @ngajhede did:
close: (nuxt) => {
if (nuxt.options._prepare) {
process.exit()
}
}
I feel like it might be useful to have some sort of "registry" of promises or long running timers so we could alert the user and even cleanly close them/time them out ofter generating. How bad would it be to extend/override/wrap the Promise class and timers to do this sort of thing?
I know this could have an effect on garbage collection, but the benefits might outweigh the negatives, and even enhance troubleshooting or debugging memory issues.
UPDATE:
Looks like my build was also hanging after it was complete like reported by other people, so I just changed the hook to:
/** @see https://github.com/nuxt/cli/issues/169 */
close: () => {
process.exit()
}
Update of update:
This doesn't work. It fails to build tsconfig.json, so I'm not sure what to do. If I remove the close hook, it builds tsconfig.json, but then never ends the build / prepare