Tailwind CSS Latest Version - How to Upgrade?

I have an old project created using Vite and React, where Tailwind CSS v3 is used for styling. In order to upgrade to Tailwind CSS v4, I ran the command:
npx @tailwindcss/upgrade@next --force

Initially, the command issued a warning related to the git cache, so I added the --force parameter. However, during execution, the following error appears:
During the first phase of running this command, I encountered a warning related to the git cache. To bypass this warning, I added the --force option. But then, during the upgrade process, the following error occurs:
Could not load the configuration file: Can't resolve

How can this problem be bypassed to successfully upgrade the project to Tailwind CSS v4? Maybe there is some kind of guide that describes the solution?

Answers

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Tomaso Ruiz

    The latest version, tailwindcss v4.0.1, has been released.
    The developer promised to fix the problem in a new version.
    I think you can try upgrading your project.

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Zavulon Arias

    Tomaso, thanks for your help with tailwind css.

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Tomaso Ruiz

    It appears that yet another solution has surfaced here.

    The original post's author mentioned that they ran the following code:
    bun i @tailwindcss/upgrade
    bun pm trust --all
    bun run upgrade

    This solved the path issue and eliminated the bug.
    Using Bun, the path problem during the upgrade is addressed by running commands to install the package and grant full trust (which is necessary for node-gyp to work correctly with the framework’s components).
    After the upgrade is done, the author recommends removing the update package by running:
    bun rm @tailwindcss/upgrade

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Zavulon Arias

    I tried updating the product version, but without success. The issue started to look different:
    ≈ tailwindcss v4.0.1
    │ Searching for CSS files in the current directory and its subdirectories…
    │ ↳ Linked `.tailwind.config.ts` to `.srcxa_appglobals.css`
    │ Migrating JavaScript configuration files…
    │ ↳ Could not load the configuration file: v is not a function

    However, there was no positive result.

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Marian Baker

    If you are working on Windows, try upgrading the project through Windows Subsystem for Linux (WSL). That’s exactly what worked for me.
    I hope this is a temporary solution until the official bug fix is released.

  • Gravatar — онлайн-сервис, позволяющий пользователям Интернета поддерживать постоянную картинку на большинстве сайтов.

    Antoni Collins

    I encountered a similar problem. It turned out that the bug in the upgrade tool is related to the handling of file paths on Windows. The function responsible for computing relative paths may fail to add the required prefix or may return an absolute path if the files are located on different drives. This results in the 'Can't resolve' error.
    Try moving the entire project to a single drive if you are using multiple partitions.