tailwindcss: ERROR Importing directly from a nuxt.config file is not allowed.

How to bypass that error?

ERROR Importing directly from a nuxt.config file is not allowed. Instead, use runtime config or a module. [importing /nuxt.config.js from index.html]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15

Commits related to this issue

Most upvoted comments

I think I have found the error on my end: I had "./nuxt.config.{js,ts}", in my tailwind.config.js. You may wonder why it is there, and here is the reason.

I removed the line and the error disappeared.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Just basic Nuxt 3 + @nuxtjs/tailwindcss installation.

After some tests looks like error is off when I comment out one line in tailwindcss config.

nuxt.config.js: import { defineNuxtConfig } from “nuxt3”

import { defineNuxtConfig } from "nuxt3"

export default defineNuxtConfig({
  tailwindcss: {
    viewer: false,
    config: {
      darkMode: "class",
      content: [
        `components/**/*.{vue,js}`,
        `composables/**/*.{vue,js}`,
        `layouts/**/*.vue`,
        `pages/**/*.vue`,
        `plugins/**/*.{js,ts}`,
        // `nuxt.config.{js,ts}`,
      ],
    },
  },
  buildModules: [
    "@nuxtjs/tailwindcss",
  ],
})

I think I have found the error on my end: I had "./nuxt.config.{js,ts}", in my tailwind.config.js. You may wonder why it is there, and here is the reason.

I removed the line and the error disappeared.

Thank you!!! Thank you!!! Thank you!!!

StackBlitz

It is to do with the content [ ] in tailwind.config

Uncomment any of the last two entries and it breaks.

./*.{vue,js,ts} is not needed here anyway as they are covered individually but nuxt.config might be needed in some situations as mentioned here

I think I have found the error on my end: I had "./nuxt.config.{js,ts}", in my tailwind.config.js. You may wonder why it is there, and here is the reason.

I removed the line and the error disappeared.

this works to me, but what does it do? does this affect any thing?

I do have this error. seemed so weird.

Thanks!

thanks a lot