3

I’m working on a Vite project where I am using Tailwind CSS, and I’ve deleted the App.css file to replace it with Tailwind's utility classes. However, I’m getting the following error: Failed to resolve import "./App.css" from "src/App.jsx". Does the file exist? My App.jsx file no longer imports App.css and contains:

import React from 'react';

const App = () => {
  return (
    <div>App</div>
  );
};

export default App;

I deleted App.css because I am not using it anymore, and I want to rely solely on Tailwind CSS for styling. However, after deleting the App.css file, I am still getting the error about it trying to resolve ./App.css from App.jsx. I have ensured that no other files are still referencing App.css. I confirmed that Tailwind CSS is properly set up and working in my project. The project runs fine when I revert to the old setup where App.css was present, but the error reappears after deleting App.css.

tailwind.config.js contains:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./index.html",  // Path to HTML files
    "./src/**/*.{js,jsx,ts,tsx}",  // Path to JS/JSX/TS/TSX files
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};

main.jsx contains:

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
)

I was following the setup from a youtube tutorial https://www.youtube.com/watch?v=zA9r5zTllx4 timestamp 00:03:48

Any help would be appreciated! Thanks in advance!

0

3 Answers 3

0

The error suggests App.css is still being imported somewhere. Since it's not in your shared files, check that the correct App.jsx file is being edited (check file path).

Then clear Vite's cache:

rm -rf node_modules/.vite
npm run dev

If you’re still getting the error, search your project for any remaining "App.css" references:

grep -r "App.css" .

You may also need to restart your development server after deleting App.css.

Sign up to request clarification or add additional context in comments.

Comments

0

Clear Cache and Rebuild:

Sometimes, cache issues can cause Vite to think the file still exists. Try clearing the cache and rebuilding your project:

rm -rf node_modules
rm -rf dist
npm install
npm run dev

Comments

-1

My solution to this error was quite simple, just ctrl + s to save file and run: npm run dev

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.