nuxt: Named export 'consola' not found

Environment

Nuxi 3.4.0


  • Operating System: Darwin
  • Node Version: v19.8.1
  • Nuxt Version: 3.4.0
  • Nitro Version: 2.3.3
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: runtimeConfig, modules, imports, app, vite, sitemap, tailwindcss, googleFonts, i18n, content
  • Runtime Modules: @nuxtjs/i18n@8.0.0-beta.10, @nuxt/content@2.5.2, @nuxtjs/tailwindcss@6.6.5, @pinia/nuxt@0.4.8, nuxt-icon@0.3.3, nuxt-headlessui@1.1.1, nuxt-simple-sitemap@2.4.8, @nuxtjs/google-fonts@3.0.0, nuxt-swiper@1.1.0, @vueuse/nuxt@9.13.0
  • Build Modules: -

Reproduction

  1. yarn nuxi upgrade --force
  2. yarn dev
  3. visit http://localhost:3000

Describe the bug

⚠️ Request Error 500: Named export ‘consola’ not found.

[nuxt] [request error] [unhandled] [500] Named export 'consola' not found.
The requested module 'consola' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'consola';
const { consola } = pkg;   

 at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)  
  at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 41
  • Comments: 41 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Experiencing the same issue after upgrading to 3.4

Workaround seems to be working.

yarn add -D consola installs in my case "consola": "^3.0.1",

Result: error no longer present

This issue is likely caused by other dependencies hoisting consola v2 to the top level.

For now, you can likely work around it by adding pnpm/npm overrides or yarn resolutions.

cc: @pi0

Same here, here is an output of pnpm why consola

devDependencies:
@nuxt/devtools 0.3.2
├─┬ @nuxt/devtools-kit 0.3.2
│ ├─┬ @nuxt/kit 3.4.0
│ │ └── consola 3.0.1
│ └─┬ nuxt 3.4.0 peer
│   ├─┬ @nuxt/kit 3.4.0
│   │ └── consola 3.0.1
│   ├─┬ @nuxt/telemetry 2.2.0
│   │ ├─┬ @nuxt/kit 3.4.0
│   │ │ └── consola 3.0.1
│   │ └── consola 3.0.1
│   ├─┬ @nuxt/vite-builder 3.4.0
│   │ └─┬ @nuxt/kit 3.4.0
│   │   └── consola 3.0.1
│   └─┬ nitropack 2.3.3
│     └── consola 3.0.1
├─┬ @nuxt/devtools-wizard 0.3.2
│ └── consola 2.15.3
├─┬ @nuxt/kit 3.4.0
│ └── consola 3.0.1
├── consola 2.15.3
└─┬ nuxt 3.4.0 peer
  ├─┬ @nuxt/kit 3.4.0
  │ └── consola 3.0.1
  ├─┬ @nuxt/telemetry 2.2.0
  │ ├─┬ @nuxt/kit 3.4.0
  │ │ └── consola 3.0.1
  │ └── consola 3.0.1
  ├─┬ @nuxt/vite-builder 3.4.0
  │ └─┬ @nuxt/kit 3.4.0
  │   └── consola 3.0.1
  └─┬ nitropack 2.3.3
    └── consola 3.0.1
@nuxt/image-edge 1.0.0-28008586.381b906
├─┬ @nuxt/kit 3.4.0
│ └── consola 3.0.1
├── consola 2.15.3
└─┬ ipx 1.0.0
  └── consola 2.15.3
@pinia/nuxt 0.4.8
└─┬ @nuxt/kit 3.4.0
  └── consola 3.0.1
@vite-pwa/nuxt 0.0.7
└─┬ @nuxt/kit 3.4.0 peer
  └── consola 3.0.1
consola 3.0.1
nuxt 3.4.0
├─┬ @nuxt/kit 3.4.0
│ └── consola 3.0.1
├─┬ @nuxt/telemetry 2.2.0
│ ├─┬ @nuxt/kit 3.4.0
│ │ └── consola 3.0.1
│ └── consola 3.0.1
├─┬ @nuxt/vite-builder 3.4.0
│ └─┬ @nuxt/kit 3.4.0
│   └── consola 3.0.1
└─┬ nitropack 2.3.3
  └── consola 3.0.1
pinceau 0.18.8
├── consola 2.15.3
├─┬ style-dictionary-esm 1.3.7
│ └── consola 2.15.3
└─┬ unbuild 1.2.0
  └── consola 2.15.3

Can be fixed by adding this into package.json if using pnpm

  "pnpm": {
    "overrides": {
      "consola": "3.0.1"
    }
  }

Just fixed locally with a temporary solution in my package.json:

  "peerDependencies": {
    "consola": "3.0.1"
  },

I experienced the same problem. In my case, running nuxi upgrade --force resolved the issue.

I hope this works.

Hi. I apologize for any issues you are encountering with this upgrade.

If you are using nuxt as a dependency in your project:

  1. Use npx nuxi upgrade --force to upgrade the lock file. Check if the issue is solved.
  2. Use pnpm why, npm-why or yarn why and check list of dependencies that are still using consola@2. Please consider reporting them here so we can track and ask them to upgrade. If hoisted (top level) consola version in results is still v2, add a resolutions field to your project’s package.json and renew lockfile or install:
{
  "resolutions": {
    "consola": "^3.0.0"
  }
}

If you are a library or module author:

  1. Check if you are directly having consola as a dependency, if you have it, upgrade to v3 and change import consola to import { consola }
  2. Followup steps above to find out about the possible sub-dependency issues
  3. Use resolutions, to fix your local development branch and followup with sub-dependency issues here to be resolved. Advice your users to use above steps in the meanwhile.

Same here with 3.4.2

Thanks @danielroe for your reply! I tried overrides because I’m using just plain ol’ npm but unfortunately it didn’t help. I added the following to my package.json:

"overrides": {
     "consola": "^3.0.0"
},

Just for the record: I got it working finally. I just put the overrides into the wrong place. My monorepo is structured like this:

nuxt/
- package.json
strapi/
- package.json
package.json

I first put the overrides into nuxt/package.json but that didn’t work. What made it work was putting it into the roots package.json.

I hope that helps some other desperate node tinkerer like me. 😃

@AliNaraghiA You are using a module that isn’t compatible with Nuxt 3.

Upstream

@sdsoldi Thanks for reporting. nuxt-config-schema is fixed you can try again by recreating lockfile.

@hermanndettmann You may need to use overrides or pnpm.overrides depending on your package manager.

Hi this issue just happened. These are the libraries who are using consola 2.X.X:

npx npm-why consola

  Who required consola:

  @nestjs/core > @nuxtjs/opencollective > consola@2.15.3

Adding consola to resolutions didn’t fix the issue, either in the nuxt app package.json or the root package.json

I have the same issue but adding a resolutions field is working fine.

pnpm why consola returns:

dependencies: @nuxtjs/sanity 1.6.0 └─┬ @nuxt/kit 3.1.0 └── consola 2.15.3

Hi I faced the same issue

and this is the result of

$ npx npm-why consola

Who required consola:

@nuxt/devtools > consola@2.15.3 @nuxt/image-edge > ipx > consola@2.15.3

@pi0 Fixed! Thanks!!!

Same here, overrides does not helps

I also experience the issue, and yes the “workaround” works npm install consola@3.0.1

However, a fresh nuxt install works, so it must be one of the modules we have installed.