12

So this is my first time using Typescript and Tailwind. I already followed tailwind guide for create-react-app but when I try to run npm start I got this error:

./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-4-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
TypeError: Object.entries(...).flatMap is not a function
    at Array.forEach (<anonymous>)

this is my index.css

@tailwind base;
@tailwind components; 
@tailwind utilities;

body {...

I got warning in index.css Unknown at rule @tailwind css(unknownAtRules)

and this is my index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
// import App from './App';
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
  <React.StrictMode>
    <div className="px-4 py-2 bg-green-500 text-white font-semibold rounded-lg hover:bg-green-700">tombol</div>
  </React.StrictMode>,
  document.getElementById('root')
);

reportWebVitals();
  • 2
    Does this answer your question? [How to add a @tailwind CSS rule to css checker](https://stackoverflow.com/questions/47607602/how-to-add-a-tailwind-css-rule-to-css-checker) – Ankush Chauhan Oct 17 '21 at 14:19

5 Answers5

10

This is strange. Try to update your Node.js to the latest current stable version and try again.

Or Assayag
  • 5,662
  • 13
  • 57
  • 93
10

Create or edit .vscode/settings.json and add:

{
  "files.associations": {
    "*.css": "tailwindcss"
  }
}

Additionally the VSCode extension is helpful - these notes are from their docs.

cyberwombat
  • 38,105
  • 35
  • 175
  • 251
  • This the answer that worked best for me. The "PostCSS Language Support" extension also fixes it, but is slow and breaks another CSS extension I use regularly (Color Info). And I just use a different PostCSS extension for Intellisense. – timmywil Jul 15 '23 at 00:45
4

Update NodeJS using nvm by following the steps from this link: https://learn.microsoft.com/en-us/windows/nodejs/setup-on-windows

Make sure you have uninstalled the previous node_modules folder from your project.

Follow these steps

Install RimRaf:
npm install rimraf -g

And in the project folder delete the node_modules folder with:
rimraf node_modules

Reference: How to Delete node_modules - Deep Nested Folder in Windows

Joshua Poddoku
  • 109
  • 1
  • 4
3

Add VS Code extension postcss language support

enter image description here

Ngodza
  • 387
  • 3
  • 8
0

Try to add file .postcssrc into root of your project with content:

{
  "plugins": {
    "tailwindcss": {}
  }
}

and tailwind.config.js with content:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Valeriy
  • 1,365
  • 3
  • 18
  • 45