Skip to content

Nuxtjs Modules Config

DodaTech 1 min read

In this tutorial, you'll learn about Nuxt.js Modules Configuration Error Fix. We cover key concepts, practical examples, and best practices.

The Problem

Module not found: Can't resolve '@nuxtjs/tailwindcss'

The Nuxt module is not installed as a dependency.

Wrong

Adding a module to nuxt.config.ts without installing it:

export default defineNuxtConfig({
  modules: ['"@nuxtjs"/tailwindcss'],
})

Output: Module not found when starting the dev server.

Install the module first:

npm install --save-dev @nuxtjs/tailwindcss

Then configure:

export default defineNuxtConfig({
  modules: ['"@nuxtjs"/tailwindcss'],
  tailwindcss: {
    configPath: 'tailwind.config.ts',
  },
})

Expected output: Tailwind CSS is available throughout the application.

Prevention

  • Install module packages before adding them to nuxt.config.ts
  • Check module documentation for compatibility with your Nuxt version
  • Use modules: [] array syntax (Nuxt 3) not buildModules (Nuxt 2)

Common Mistakes with modules config

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world NUXTJS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between `modules` and `buildModules` in Nuxt?

Nuxt 3 uses only modules for all modules. Nuxt 2 had buildModules for dev-only modules and modules for runtime modules. In Nuxt 3, use modules for everything.

How do I configure a Nuxt module with options?

Use the array syntax: modules: [['"@nuxtjs"/tailwindcss', { configPath: 'custom-path' }]] or modules: [{ src: '"@nuxtjs"/tailwindcss', options: { ... } }].

Why does my module work in dev but fail in production?

The module may have different behavior in production mode. Check if the module requires specific environment variables or build-time configuration that is only available in production.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro