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.

Nuxt 3 issue "Cannot read property 'resolveAlias' of undefined"

See original GitHub issue

Version

@nuxtjs/tailwindcss: 4.2.1 nuxt: nuxt3@3.0.0-27234271.da7ff44

Reproduction Link

https://codesandbox.io/s/hungry-diffie-k8odx

Steps to reproduce

none

What is Expected?

no error to be produced

What is actually happening?

error is produced:

ERROR  Cannot restart nuxt:  Cannot read property 'resolveAlias' of undefined
  at Object.tailwindCSSModule (node_modules/@nuxtjs/tailwindcss/dist/index.js:51:36)
  at installModule (node_modules/@nuxt/kit/dist/index.mjs:1196:17)
  at initNuxt (node_modules/nuxt3/dist/index.mjs:817:11)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6762:9)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:53
  • Comments:29 (3 by maintainers)

github_iconTop GitHub Comments

27reactions
neilmispelaarcommented, Oct 14, 2021

Thank you @productfrontenddeveloper

What got it working for my repo was:

import { defineNuxtConfig } from "nuxt3";

export default defineNuxtConfig({
  build: {
    postcss: {
      postcssOptions: {
        plugins: {
          tailwindcss: {},
          autoprefixer: {},
        },
      },
    },
  },
});

I’m still learning nuxt but that build definition seemed to get things running

22reactions
dacoto97commented, Oct 13, 2021

I think this package is no longer needed, because nuxt now uses webpack 5 and already supports tailwindcss. Install tailwind as next.js:

  1. Install Tailwind via npm npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
  2. Create your configuration file: npx tailwindcss init -p
  3. Configure Tailwind to remove unused styles in production
// tailwind.config.js
module.exports = {
  mode: "jit",
  purge: [
    './components/**/*.{vue,js}',
    './layouts/**/*.vue',
    './pages/**/*.vue',
    './plugins/**/*.{js,ts}',
    './nuxt.config.{js,ts}',
  ],
  darkMode: false, // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {},
  },
  plugins: [],
}

  1. Include Tailwind in your CSS
/* ./assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt 3 issue "Cannot read property 'resolveAlias' of undefined"
Create your configuration file: npx tailwindcss init -p; Configure Tailwind to remove unused styles in production. // tailwind.config.js module.
Read more >
vue nuxt TypeError: Cannot read properties of undefined ...
Answering myself. It was just required to use auth-next instead of auth. '@nuxtjs/auth-next',.
Read more >
The alias Property - Nuxt
This option lets you define aliases to directories within your project (in addition to the ones above). These aliases can be used within...
Read more >
Resolve | webpack
Setting resolve.alias to false will tell webpack to ignore a module. ... When the target property is set to webworker , web ,...
Read more >
Introduction to Nuxt 3 modules - DEV Community ‍ ‍
I only get Unresolved variable $strapi / Cannot read properties of undefined (reading '$strapi') error messages. Do you have any idea what the ......
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