question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module '"nuxt"' has no exported member 'defineNuxtConfig'.

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v16.4.2
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: npm@7.18.1
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Should be obvious. Error occurs after installing nuxt 3 Here is my package:

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --hostname 'localhost' --port 8083",
    "start": "node .output/server/index.mjs",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "@nuxtjs/vuetify": "^1.12.3",
    "nuxt": "^3.0.0"
  },
  "dependencies": {
    "@mdi/font": "^7.0.96",
    "@nuxt/types": "^2.15.8",
    "@pinia/nuxt": "^0.4.4",
    "@types/leaflet": "^1.7.11",
    "@types/luxon": "^2.3.2",
    "@vuepic/vue-datepicker": "^3.3.0",
    "axios": "^0.27.2",
    "click-outside-vue3": "^4.0.1",
    "leaflet": "^1.8.0",
    "luxon": "^2.4.0",
    "pinia": "^2.0.24",
    "sass": "^1.56.1",
    "vue-advanced-cropper": "^2.8.3",
    "vue-dndrop": "^1.2.13",
    "vue-waypoint": "^4.2.1",
    "vuetify": "^3.0.0"
  }
}

Describe the bug

Screenshot 2022-11-18 at 16 03 04

nuxt.config.ts

import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  css: ['vuetify/lib/styles/main.sass', '@mdi/font/css/materialdesignicons.min.css', '@/assets/sass/main.sass', 'leaflet/dist/leaflet.css'],
  build: {
    transpile: ['vuetify'],
  },
  serverMiddleware: [
    '~/server-middleware/https-redirect'
  ],
  vite: {
    define: {
      'process.env.DEBUG': false,
    },
  },
  modules: [
    '@pinia/nuxt'
  ],
  runtimeConfig: {
    public: {
      API_BASE_URL: process.env.API_BASE_URL,
      PUBLIC_API_USERNAME: process.env.PUBLIC_API_USERNAME,
      PUBLIC_API_PASSWORD: process.env.PUBLIC_API_PASSWORD,
    }
  },
  ssr: false, // Disable server side rendering
  meta: {
    title: 'Smart Wendeler Land',
  }
})

Additional context

No response

Logs

ERROR  Cannot start nuxt:  (0 , _nuxt.defineNuxtConfig) is not a function                                                                                                                                 16:03:58

  at nuxt.config.ts:4:43
  at Object.jiti (node_modules/jiti/dist/jiti.js:1:247502)
  at resolveConfig (node_modules/c12/dist/index.mjs:221:24)
  at loadConfig (node_modules/c12/dist/index.mjs:104:40)
  at async loadNuxtConfig (node_modules/@nuxt/kit/dist/index.mjs:446:18)
  at async loadNuxt (node_modules/nuxt/dist/index.mjs:1835:19)
  at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6768:23)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6840:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:50:20)

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
tkofhcommented, Nov 18, 2022

As described here, if you need/want to manually import the function it should be from nuxt/config:

import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
  // My Nuxt config
})
2reactions
tkofhcommented, Nov 18, 2022

Not broken, that message tells you that serverMiddleware is not a property of NuxtConfig. Check out the server directory documentation for how to work with server middleware, and the nuxt.config.ts documentation for what properties are allowed in your config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxt3 does not export NuxtConfig · Issue #1038 · nuxt/framework
I am using following config for my project that I successfully migrated to @nuxt/bridge (thanks for your efforts!) import { defineNuxtConfig, ...
Read more >
Migrating from Nuxt 2 to Nuxt 3 - Debbie O'Brien
I now had no files or folders at root level except the nuxt2 folder. ... from 'nuxt'export default defineNuxtConfig({ modules: ...
Read more >
NUXT 3 Module Error on adding ant-design-vue
After 2 day research finally I got the working solution. Adding ant-design-vue and icons into NUXT 3 projects. Install deps.
Read more >
Configuration · Get Started with Nuxt
A minimal configuration file exports the defineNuxtConfig function containing an object with your configuration. The defineNuxtConfig helper is globally ...
Read more >
Understanding the Directory structure in Nuxt 3 - Vue School
But one thing I am always proud of with Nuxt 3 is that its directory ... //~nuxt.config.ts export default defineNuxtConfig({ modules: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found