nuxt: Error after upgrading to Nuxt 3.8.2: `[ERROR] No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"`

Environment

Working directory: /home/stefano/Sviluppo/Personali/nuxt-storyblok-starter                                              12:05:18
Nuxt project info:                                                                                                      12:05:18

------------------------------
- Operating System: Linux
- Node Version:     v18.18.2
- Nuxt Version:     3.8.2
- CLI Version:      3.10.0
- Nitro Version:    2.8.0
- Package Manager:  pnpm@8.10.5
- Builder:          -
- User Config:      css, modules, extends, runtimeConfig, image, storyblok, tailwindcss, veeValidate, gtm, app, build
- Runtime Modules:  @storyblok/nuxt@5.7.7, @nuxtjs/tailwindcss@6.9.5, nuxt-icon@0.6.6, @vueuse/nuxt@10.6.1, @nuxt/image@1.1.0, @nuxt/devtools@1.0.3, @zadigetvoltaire/nuxt-gtm@0.0.13, @vee-validate/nuxt@4.11.8, @stefanobartoletti/nuxt-social-share@0.3.0
- Build Modules:    -
------------------------------

Reproduction

  • Update from previous version to Nuxt 3.8.2 by using npx nuxi upgrade --force
  • Run pnpm dev, the following error occurs
  • pnpm generate then pnpm preview does not seem to report any obvious error

Describe the bug

Error output:

✘ [ERROR] No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"

    node_modules/.pnpm/globby@14.0.0/node_modules/globby/ignore.js:8:8:
      8 │ import {toPath} from 'unicorn-magic';
        ╵         ~~~~~~

✘ [ERROR] No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"

    node_modules/.pnpm/globby@14.0.0/node_modules/globby/index.js:7:8:
      7 │ import {toPath} from 'unicorn-magic';
        ╵         ~~~~~~


 ERROR  [unhandledRejection] Build failed with 2 errors:                                                                11:53:08
node_modules/.pnpm/globby@14.0.0/node_modules/globby/ignore.js:8:8: ERROR: No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"
node_modules/.pnpm/globby@14.0.0/node_modules/globby/index.js:7:8: ERROR: No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"

  node_modules/.pnpm/globby@14.0.0/node_modules/globby/ignore.js:8:8: ERROR: No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"
  node_modules/.pnpm/globby@14.0.0/node_modules/globby/index.js:7:8: ERROR: No matching export in "node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/default.js" for import "toPath"
  at failureErrorWithLog (node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1649:15)
  at node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1058:25
  at node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild/lib/main.js:1525:9
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Additional context

The error seems to originate in globby@14.0.0, in my lockfile this version is used only by:

  • @nuxt/kit@3.8.2
  • nitropack@2.8.0
  • nuxt@3.8.2

unicorn-magic@0.1.0 is present in my lockfile only as a dependency of globby@14.0.0

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 30 (8 by maintainers)

Most upvoted comments

toPath is only exported in node environments: https://unpkg.com/browse/unicorn-magic@0.1.0/node.js.

The issue here is that the storyblok module was pulling the module/build-time code into the runtime context by adding it to vite.optimizeDeps.include.

I’ve raised https://github.com/storyblok/storyblok-nuxt/pull/662 which fixes the issue and should also speed up your dev server environment.

If anyone is experiencing this and isn’t using @storyblok/nuxt, let me know. 🙏

‘globby’ was updated to v14.0.0 a couple weeks back, which introduced an import for ‘toPath’ from the author’s ‘unicorn-magic’ package, which has one release and no export named toPath. Seems like an error by the author maybe?

Globby v13.2.2 does not have that import, so overriding or using resolutions to set globby to v13.2.2 for the time being worked for me:

In package.json:

"resolutions": {
    "globby": "13.2.2"
}

fixed this by adding “globby” to build.transpile.

@danielroe Thank you very much!

I’m sorry! I have find hot to resolve problem “nuxt-simple-sitemap”: “^3.4.1”, must be updated to “4.1.6” so issue now is closed but will be better to have a more clear stacktrace to understand problem without remove module by module this stack said problem in globby with using in nuxt.