【问题标题】:Nuxt.config.ts : Module '"nuxt"' has no exported member 'defineNuxtConfig'. when importing 'defineNuxtConfig'Nuxt.config.ts:模块 \'\"nuxt\"\' 没有导出成员 \'defineNuxtConfig\'。导入 \'defineNuxtConfig\' 时
【发布时间】:2023-02-09 04:43:29
【问题描述】:

I created a Nuxt 3 project, my nuxt.config.ts looked like this :

export default defineNuxtConfig({
  css: ['vuetify/lib/styles/main.sass'],
  build: {
    transpile: ['vuetify'],
  },
  vite: {
    define: {
      'process.env.DEBUG': false,
    },
  },
  ssr: false 
  
})

This works with that.

But i wanted to use .env variable so i read that i need to add :

env: {
    baseUrl: process.env.BASE_URL
  },

When i add it to the nuxt.config.ts, after the "ssr", i got the error :

"Object literal may only specify known properties, and 'env' does not exist in type 'NuxtConfig'"

So i read that most of people have a import of defineNuxtConfig so i wanted to add it to my file :

import { defineNuxtConfig } from "nuxt";
export default defineNuxtConfig({
  css: ['vuetify/lib/styles/main.sass'],
  build: {
    transpile: ['vuetify'],
  },
  vite: {
    define: {
      'process.env.DEBUG': false,
    },
  },
  env: {
    baseUrl: process.env.BASE_URL
  },
  
  ssr: false 
})

But now i have the error "Module '"nuxt"' has no exported member 'defineNuxtConfig'"

Any ideas ? :D

  • Did you manage to solve this? Having the same issue :)

标签: typescript nuxt.js nuxtjs3


【解决方案1】:

nuxt 包已经改变了。你需要更换这个

import { defineNuxtConfig } from "nuxt";

有了这个

import { defineNuxtConfig } from "nuxt/config"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-09
    • 2017-05-20
    • 2017-05-07
    • 2017-08-18
    • 1970-01-01
    • 2022-01-12
    • 2021-12-19
    相关资源
    最近更新 更多