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
- yarn nuxi upgrade --force
- yarn dev
- 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
- Update libs - Add recommendation to fix https://github.com/nuxt/nuxt/issues/20209 — committed to locokit/locokit by Alketta a year ago
- chore(portal): fix consola package problem https://github.com/nuxt/nuxt/issues/20209 — committed to ActionLabNetwork/ourvoice by knthmn a year ago
Experiencing the same issue after upgrading to 3.4
Workaround seems to be working.
yarn add -D consolainstalls 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 consolaCan be fixed by adding this into
package.jsonif usingpnpmJust fixed locally with a temporary solution in my
package.json:I experienced the same problem. In my case, running
nuxi upgrade --forceresolved 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:
npx nuxi upgrade --forceto upgrade the lock file. Check if the issue is solved.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 aresolutionsfield to your project’spackage.jsonand renew lockfile or install:If you are a library or module author:
consolaas adependency, if you have it, upgrade tov3and changeimport consolatoimport { consola }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
Just for the record: I got it working finally. I just put the
overridesinto the wrong place. My monorepo is structured like this:I first put the overrides into
nuxt/package.jsonbut that didn’t work. What made it work was putting it into the rootspackage.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
overridesorpnpm.overridesdepending on your package manager.Hi this issue just happened. These are the libraries who are using consola 2.X.X:
Adding consola to resolutions didn’t fix the issue, either in the nuxt app
package.jsonor the rootpackage.jsonI have the same issue but adding a resolutions field is working fine.
pnpm why consolareturns:Hi I faced the same issue
and this is the result of
Who required consola:
@pi0 Fixed! Thanks!!!
Same here,
overridesdoes not helpsI also experience the issue, and yes the “workaround” works
npm install consola@3.0.1However, a fresh nuxt install works, so it must be one of the modules we have installed.