skip to Main Content

I’m creating a project using vite react-ts, then I’m trying to install the package @material-tailwind/react, I’ve made sure the package is installed in package.json with version

"@material-tailwind/react": "^2.0.7",

I’ve also configured tailwind.config.js as follows:

import withMT from "@material-tailwind/react/utils/withMT";

/** @type {import('tailwindcss').Config} */
module.exports = withMT({
  content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
  theme: {
    extend: {},
    colors: {
      palette: {
        bg: "#f8f9fa",
        white: "#fff",
        down: "#FF1700",
        up: "#06FF00",
        100: "#4B49AC",
        200: "#eef2ff",
        300: "#7DA0FA",
        400: "#7978E9",
        500: "#F3797E",
      },
    },
  },
  plugins: [],
});

in the main.tsx section, I have also configured the following:

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index. css";

import { ThemeProvider } from "@material-tailwind/react";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React. StrictMode>
    <ThemeProvider>
      <App />
    </ThemeProvider>
  </React. StrictMode>
);

why when I hover over import { ThemeProvider } from "@material-tailwind/react" I get typescript error ‘Cannot find module ‘@material-tailwind/react’ or its corresponding type declarations.’?

how to solve that error?

2

Answers


  1. I found the same issue for version v2.0.7. You can either downgrade the package to v2.0.6 (or older) or try this way:

    const withMT = require('@material-tailwind/react/src/utils/withMT');
    
    Login or Signup to reply.
  2. I have the same error, when I downgrade then it finds the package but it gives me the following error:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search