Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: withTV causes "Module not found: Can't resolve 'fs'" error in Next.js #212

Open
phuoclt-sens opened this issue Aug 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@phuoclt-sens
Copy link

When using the withTV function from tailwind-variants in a Next.js project, I encounter the following error:
Module not found: Can't resolve 'fs'

To Reproduce

Steps to reproduce the behavior:
Set up a Next.js project with tailwindcss and tailwind-variants.
Use withTV in the Tailwind configuration, such as in tailwind.config.js:

const { withTV } = require('tailwind-variants/transformer');

module.exports = withTV({
  theme: {
    extend: {
      // Your customizations
    },
  },
});

Run the Next.js development server using npm run dev.
Observe the error in the terminal or browser console.

System Information:

Next.js version: 14.2.5
Node.js version: 20.16.0
Tailwind CSS version: 3.4.1
Tailwind Variants version: 0.2.1
Operating System: macOS

image
@phuoclt-sens phuoclt-sens added the bug Something isn't working label Aug 22, 2024
@phamhuutinh0605
Copy link

Ohhhh, i have same issue @@

@jmichaliga
Copy link

Also having the same problem with a NextJS project. Is there any update on this with a webpack polyfill?

@kpyszkowski
Copy link

Resolved by adding Webpack exception for fs module in Next config:

/** @type {import('next').NextConfig} */
const nextConfig = {
  // ...
  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.resolve = {
        ...config.resolve,
        fallback: {
          fs: false,
        },
      }
    }
    return config
  },
}

export default nextConfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants