5

I tried to install Nuxt 3 layers inside a monorepo with turborepo. and I somehow get error with typescript where it's seems to not able to figure out nuxt

defineNuxtConfig not find

appConfig not found

the ts config file look like this:

{
  "extends": "./.playground/.nuxt/tsconfig.json"
}

and on .playground/.nuxt folder there's tsconfig that look like this(auto-generated):

// Generated by nuxi
{
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "jsx": "preserve",
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "skipLibCheck": true,
    "strict": true,
    "allowJs": true,
    "noEmit": true,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "types": [
      "node"
    ],
    "baseUrl": "..",
    "paths": {
      "~": [
        "."
      ],
      "~/*": [
        "./*"
      ],
      "@": [
        "."
      ],
      "@/*": [
        "./*"
      ],
      "~~": [
        "."
      ],
      "~~/*": [
        "./*"
      ],
      "@@": [
        "."
      ],
      "@@/*": [
        "./*"
      ],
      "assets": [
        "assets"
      ],
      "public": [
        "public"
      ],
      "#app": [
        "../../../node_modules/nuxt/dist/app"
      ],
      "#app/*": [
        "../../../node_modules/nuxt/dist/app/*"
      ],
      "vue-demi": [
        "../../../node_modules/nuxt/dist/app/compat/vue-demi"
      ],
      "@vueuse/head": [
        "../../../node_modules/@unhead/vue/dist/index"
      ],
      "#imports": [
        ".nuxt/imports"
      ],
      "#build": [
        ".nuxt"
      ],
      "#build/*": [
        ".nuxt/*"
      ],
      "#components": [
        ".nuxt/components"
      ]
    }
  },
  "include": [
    "./nuxt.d.ts",
    "../**/*"
  ],
  "exclude": [
    "../dist",
    "../.output"
  ]
}

how can i fix this so that defineNuxtConfig is recognized properly?

remove error Cannot find name 'defineNuxtConfig'.ts(2304)

wypratama
  • 51
  • 1
  • 3
  • Did u manage to solve the issue? It is impacting auto import on the whole layer which is very annoying to keep consistency across the monorepo – BghinC Jun 15 '23 at 16:11

2 Answers2

10

I had the same problem, weirdly enough after trying a few things what fixed it for me was changing the VSCode plugin Volar:Typescript Version to Use workspace version THEN changing back to Use VS Code's Version

image

How:

  1. On VSCode press F1 or Ctrl + Shift + P
  2. Type Volar: Select Typescript Version
  3. Select Use workspace version
  4. Repeat steps 1 & 2
  5. But this time select Use VS Code's Version

Bam, all my nuxt3 autoimports are correctly typed, don't know why tho.

Terpsikhore
  • 119
  • 1
  • 3
6

Not an automatic solution, but you can import the symbol manually:

import { defineNuxtConfig } from 'nuxt/config'
Reza Hajianpour
  • 707
  • 1
  • 10
  • 21