Search code examples
tailwind-css

Adding node_modules to the content in React tailwind.config results in an error


I am working on a React project composed of CRA.

An error occurred when I matched the tailwind settings and added the relevant settings to tailwind.config to use the local library with tailwind.

//tailwind.config.js

module.exports = {
    content: [
        "./src/**/*.{js,jsx,ts,tsx}",
        "./src/components/**/*.{js,jsx,ts,tsx}",
        "./node_modules/**/*.{js,jsx,ts,tsx}"
    ],

The errors are as follows enter image description here


Solution

  • It seems like your node_modules path might be too broad and covering more than you intend. This could lead to errors as you provided. Consider changing the node_modules to be more specific to the library you are consuming, like ./node_modules/my-library/**/*.js.