The error "defineNuxtConfig is not defined" occurs
Asked Answered
F

3

7

Situation

npx nuxi init my-project-name
cd my-project-name
npm install

When I run this command, I get the error "defineNuxtConfig is not defined."

I have tried reinstalling node.js, but to no avail.
What could be the cause of this error?

Version
node: 18.15.0
nuxt: 3.3.2
npm: 9.5.0

Reinstall node.js Reinstall npm, npx, typescript, nuxt global packages

Flocculus answered 1/4, 2023 at 9:48 Comment(1)
is this a linting error?Sanches
C
9

Substantiating on Matthew Dean's comment a bit, and in my case a warning appeared since I configured ESlint. However, the app should still run with this warning, well, as the doc suggests (https://nuxt.com/docs/guide/directory-structure/nuxt.config), the following solved it:

You can explicitly import defineNuxtConfig from nuxt/config if you prefer:

import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
  // My Nuxt config
})

Hope it helps someone else!

Conglomeration answered 14/6, 2023 at 23:42 Comment(0)
C
1

For me, the problem was my installed Vue.js version was 2.17 and i needed to use vue 3 for my project. Go to terminal, write

npm list

if you see your Vue and Nuxt version lower than expected you may face this issue. try to get latest version of Vue. enter image description here

Caddaric answered 26/1 at 12:16 Comment(0)
G
0

You have this on your nuxt config?

import { defineNuxtConfig } from 'nuxt3';

export default defineNuxtConfig({

});
Gibby answered 1/4, 2023 at 18:22 Comment(2)
I tried that too, but it didn't change the results. Thanks for your suggestion.Flocculus
import { defineNuxtConfig } from 'nuxt/config'Noon

© 2022 - 2024 — McMap. All rights reserved.