unplugin-vue-components icon indicating copy to clipboard operation
unplugin-vue-components copied to clipboard

Upgrade chokidar to fix Nuxt 4 Nitro build

Open twinkelmann opened this issue 2 months ago • 1 comments

I recently upgraded @nuxt/ui to version 4, which uses your package unplugin-vue-components version 29.1.0.

This pulls a dependency for chokidar version 3.6.0, which itself pulls a dependency for anymatch 3.1.3, which itself pulls a dependency for a very outdated version of picomatch, version 2.3.1, before they removed the dependency on the "path" nodejs library.

This causes the following error when building a Nuxt 4 project:

ℹ Building Nuxt Nitro server (preset: cloudflare-pages, compatibility date: 2025-03-01)                          nitro 16:34:16
node_modules/.pnpm/[email protected]/node_modules/mime/dist/src/Mime.js (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/.pnpm/[email protected]/node_modules/mime/dist/src/Mime.js (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/.pnpm/[email protected]/node_modules/picomatch/lib/constants.js (2:7): Error when using sourcemap for reporting an error: Can't resolve original location of error.

[nitro 16:34:33]  ERROR  RollupError: node_modules/.pnpm/[email protected]/node_modules/picomatch/lib/constants.js (2:7): "default" is not exported by "node:path?commonjs-external", imported by "node_modules/.pnpm/[email protected]/node_modules/picomatch/lib/constants.js".


1: import * as commonjsHelpers from "commonjsHelpers.js";
2: import require$$0 from "\u0000node:path?commonjs-external";
          ^
3: 
4: 'use strict';

anymatch has not been updated in 3 years, so this is to be expected. However, chokidar version 4 dropped all dependencies except one, including the drop of anymatch.

I don't know how no one else got this error, but I think it would be beneficial for everyone if your project upgraded to chokidar version 4.

twinkelmann avatar Oct 15 '25 16:10 twinkelmann

As I mentionned on https://github.com/nuxt/ui/issues/5241, Turns out the issue was already there in Nuxt UI 3 but only occurs with Nuxt 4's stricter requirements for ES module (ESM) compatibility. And since the migration guide (https://ui.nuxt.com/docs/getting-started/migration/v4) says

Nuxt UI v4 requires Nuxt 4 due to some dependencies. Make sure to upgrade to Nuxt 4 before migrating to Nuxt UI v4.

it's going to become an issue when upgrading to version 4

twinkelmann avatar Oct 15 '25 16:10 twinkelmann