nuxt: cannot import from `nuxt/app` (Package import specifier "#build/app.config.mjs" is not defined)

Environment

Operating System: MacOS Ventura Node Version: v16.13.0. Nuxt Version: 3.0.0-rc.9 Nitro Version: 0.5.0 Package Manager: yarn@1.22.19 Builder: webpack ( I think) User Config: Runtime Modules: “dependencies”: { “@formkit/i18n”: “^1.0.0-beta.10”, “@pinia/nuxt”: “^0.4.1”, “axios”: “^0.27.2”, “pinia”: “^2.0.21”, “pinia-plugin-persistedstate”: “^2.1.1”, “postmark”: “^3.0.1”, “swiper”: “^8.3.1”, “vue3-marquee”: “^3.0.7” } Build Modules: “devDependencies”: { “@aceforth/nuxt-netlify”: “^1.1.0”, “@formkit/nuxt”: “^1.0.0-beta.11-0dd967c”, “@iconify-json/heroicons-solid”: “^1.1.1”, “@nuxtjs/tailwindcss”: “^5.3.2”, “@tailwindcss/typography”: “^0.5.7”, “@vueuse/core”: “^9.1.1”, “@vueuse/nuxt”: “^9.1.1”, “netlify-cli”: “^11.5.1”, “nuxt”: “3.0.0-rc.9”, “unplugin-icons”: “^0.14.5” }

Reproduction

I upgrade with yarn upgrade and with yarn upgrade nuxt, then yarn upgrade --force, and then yarn upgrade --latest. I upgraded to RC.9 and a few packages that didn’t work I upgraded manually to the edge repository like formkit that needed yarn add @formkit/nuxt@next --dev .

I’will try to make a minimal reproduction, but as the project has many pages and components Im not sure if I have to recreate the whole project.

Describe the bug

When I do yarn build -> the site is completely broken it doesn’t load any page. When I do yarn dev -> the site works ok When I do yarn check -> There is 1 error

error "@pinia/nuxt#unctx#unplugin#vite@^2.3.0" doesn't satisfy found match of "vite@3.0.9"
error Found 1 errors.

Additional context

No response

Logs

[nuxt] [request error] [unhandled] [500] Package import specifier "#build/app.config.mjs" is not defined in package /Users/david/WebstormProjects/mixverde/.output/server/node_modules/nuxt/package.json imported from /Users/david/WebstormProjects/mixverde/.output/server/node_modules/nuxt/dist/app/config.mjs
  at new NodeError (node:internal/errors:371:5)  
  at throwImportNotDefined (node:internal/modules/esm/resolve:429:9)  
  at packageImportsResolve (node:internal/modules/esm/resolve:778:3)  
  at moduleResolve (node:internal/modules/esm/resolve:924:21)  
  at defaultResolve (node:internal/modules/esm/resolve:1044:11)  
  at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)  
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)  
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)  
  at link (node:internal/modules/esm/module_job:75:36)```

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 38 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Please ensure you are not importing directly from nuxt/app but from #imports.

I bumped my dependency and I am facing this issue with histoire.

I get: TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#build/app.config.mjs" is not defined in package node_modules/nuxt/package.json imported from node_modules/nuxt/dist/app/config.mjs

The line in question is: import __appConfig from "#build/app.config.mjs";

Still see this with Histoire

same for me as @Lyokolux but with vitest

I fixed it by inlining nuxt as a dep

And my IDE says now image

and there is furthermore also no type inference possilbe now?

No, your Nuxt config is the one place you should import anything from nuxt in your project.

I see, @danielroe thanks for clarifying that. I changed it in one place but the problem persist. as far as I can see I was importing from one plugin so I changed it from import {defineNuxtPlugin, useCookie} from ‘#app’ to import {defineNuxtPlugin, useCookie} from ‘#imports’

same for me as @Lyokolux but with vitest

@ChurikiTenna Would you open a new issue with a reproduction?

I have a similar issue and have created an issue with reproduction over here: https://github.com/histoire-dev/histoire/issues/430

I’m talking about vitest config - see https://vitest.dev/config/#deps-inline

same here. im using npm and upgrading from rc8