#nuxt dev fails to run with chokidar error

5 messages · Page 1 of 1 (latest)

wide shoreBOT
#

Hi @pure moat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

It looks like you're encountering a chokidar-related error when running npm run dev with Nuxt, specifically:

[unhandledRejection] UNKNOWN: unknown error, watch '/Users/johan/Projects/storefront/${port}'

Based on the knowledge sources, here are some relevant points:

  • Nuxt uses chokidar for file watching, and recent updates have moved to chokidar v4, which no longer supports glob patterns and has some changes in how ignore patterns are handled. This could potentially cause issues if your configuration or dependencies are not aligned with these changes chore(deps): update dependency chokidar to v4 (main), fix(kit,nuxt,schema,vite): improve watching behaviour.
  • The watchers configuration in nuxt.config allows you to pass options directly to chokidar. If you have custom watcher settings, especially ignore patterns, ensure they are compatible with chokidar v4 (i.e., use regexps instead of globs) watchers config docs.
  • The error path includes ${port}, which suggests there might be a misconfiguration or an environment variable not being interpolated correctly in your paths. This could cause chokidar to attempt to watch an invalid directory.
#

What you can try:

  1. Check your watcher configuration in nuxt.config for any dynamic paths or patterns that might not be resolving correctly.
  2. Ensure all dependencies are up to date, especially chokidar and related packages, as recent updates have fixed several watcher issues fix(kit,nuxt,schema,vite): improve watching behaviour.
  3. Look for any environment variables or template strings in your configuration that might not be set or interpolated as expected (e.g., ${port} showing up literally).
  4. If you are using Nuxt Content or other modules with their own watcher settings, check their configuration as well Nuxt Content watch config.

If after these checks the issue persists, the knowledge sources do not provide a direct solution for this specific error message. It may be helpful to share your nuxt.config and any custom watcher-related code for further troubleshooting.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@pure moat Kapa.ai is still learning and improving, please let me know how I did by reacting below.

pure moat
#

I don't have any custom watchers in nuxt.config.

I am using the latest nuxt version.

The only port related environment variable is NITRO_PORT in .env.