Skip to content

'require' not define, cannot import plugin to tailwind config #151

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

Closed
vim-diesel opened this issue Nov 9, 2023 · 6 comments
Closed

'require' not define, cannot import plugin to tailwind config #151

vim-diesel opened this issue Nov 9, 2023 · 6 comments

Comments

@vim-diesel
Copy link

What version of @tailwindcss/forms are you using?

10.2.3

What version of Node.js are you using?

v20.9.0

What browser are you using?

Edge

What operating system are you using?

Windows

Reproduction repository

https://github.com/vim-diesel/vite-eslint

Describe your issue

Attempting to import the plugin to tailwind.config.js throws an error:

image

@vim-diesel
Copy link
Author

I may have found a fix, although I'm not sure if it is a fix or a bandaid:

To specify environments in a configuration file, use the env key and specify which environments you want to enable by setting each to true. For example, the following enables the browser, es6 and Node.js environments:

In your .eslintrc.js file ;

env: {
   browser: true,
   node: true,    <<<<--- Add this
   es6: true
 },

@thecrypticace
Copy link
Contributor

Hey, this is a project configuration thing — especially given that these errors are coming from ESLint.

However, if you're in a Vite project I'd suggest using import instead of require anyway as this is the proper way to do this when using ES Modules:

import formsPlugin from '@tailwindcss/forms'

/** @type {import('tailwindcss').Config} */
export default {
  content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
  theme: {
    extend: {},
  },
  plugins: [formsPlugin],
}

@shivangi-2001
Copy link

Remove this plugin install in vscode
image

@Pizle0210
Copy link

##solution##
This worked for me.

change from module to common js in tailwind.config

Screenshot From 2024-11-08 16-03-41

@yamanidev
Copy link

@Pizle0210 did you change the file from tailwind.config.ts to tailwind.config.cjs?

kitswas pushed a commit to iiith-cs24-sp/citestat that referenced this issue Nov 19, 2024
Require() was failing with Node 23 on MacOS.
See tailwindlabs/tailwindcss-forms#151 (comment)
harrisony added a commit to harrisony/homebox that referenced this issue Jan 4, 2025
harrisony added a commit to harrisony/homebox that referenced this issue Jan 4, 2025
harrisony added a commit to harrisony/homebox that referenced this issue Jan 4, 2025
harrisony added a commit to harrisony/homebox that referenced this issue Jan 4, 2025
@iyouushh
Copy link

iyouushh commented Jan 21, 2025

Issue: Adding tailwindcss-animate plugin to Tailwind config

Steps to Reproduce

  1. Install the plugin using npm install tailwindcss-animate.
  2. Modify the tailwind.config.js file to include the plugin:
    import plugin from "tailwindcss-animate";
    
    export default {
      content: [
        "./src/**/*.{js,ts,jsx,tsx,mdx}", // Update with your project's paths
      ],
      theme: {
        extend: {},
      },
      plugins: [plugin],
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants