57

screens/HomeScreen.js: Use process(css).then(cb) to work with async plugins

Here is my HomeScreen.js

import { View, Text } from 'react-native'
import React from 'react'

export default function HomeScreen() {
  return (
    <View>
      <Text className="text-red">HomeScreen</Text>
    </View>
  )
}

I am trying to use tailwindcss in React Native with Nativewind. Here is the link I am following.

1

14 Answers 14

107

I solved this error by changing the version to 3.3.2 and using yarn instead of npm.

Here are the commands I followed:

yarn add nativewind
yarn add --dev [email protected]
2
  • Thank you Muhammad! I upgraded from Expo SDK 47 to 48 and this provided a nice quick fix to many of my bug fix issues. Commented Jul 14, 2023 at 20:10
  • 8
    Just downgrading to 3.3.2 was enough for me. No need to change to yarn. Commented Jul 16, 2023 at 15:02
53

I have also got the same error when I install the tailwindcss with npm.

I have solved this by downgrading the tailwindcss to 3.3.2

npm install [email protected] --save-dev
2
  • 5
    --dev is not an option for NPM. Use npm i -D [email protected] instead.
    – Chen W
    Commented Aug 25, 2023 at 16:43
  • you can use --save-dev, as Venkata writes
    – Lasse
    Commented Feb 10 at 22:01
24

in package.json change "tailwindcss": "^3.3.2", to "tailwindcss": "3.3.2",

0
8

run this guys

yarn remove nativewind
yarn remove tailwindcss
yarn add [email protected]
yarn add --dev [email protected]
yarn add nativewind

if using npm use npm instead of yarn <3

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 14, 2023 at 9:03
7

09.08.2023 Error

Recently have experienced the same error in Expo SDK 49. Current solution is to change the tailwindcss version to 3.3.2.

Here is how to do it:

yarn add nativewind
yarn add --dev [email protected]
7

Remove nativewind

npm uninstall nativewind

Remove tailwindcss

npm uninstall tailwindcss

Add [email protected] as a development dependency

npm install --save-dev [email protected]

Add nativewind

npm install nativewind

1
  • Really this order matters the configuration is this way correct. I first intalled nativewind and then tailwind css then was getting the same error. But followed this answer and this worked like magic, and now I am enjoying tailwind in react-native Commented Jun 22 at 16:56
5

For sure the problem was the version of tailwindcss, I was using 3.3.3, and I downgraded to version 3.3.2 and it worked just fine.

npm i --dev [email protected] or yarn add --dev [email protected]

enter image description here

3

Also with expo you can fix it installing:

npm i tailwindcss": "3.3.2"  
# or 
yarn add tailwindcss": "3.3.2"
3

I solved this error by changing the version to 3.3.2.

Here are the commands I followed:

npm i --dev [email protected]
# or 
yarn add --dev [email protected]
1

This worked for me:

Assuming you've installed nativewind (yard add nativewind)

1

Wanted to add the following piece of information which may be helpful to anyone using firebase.

Even after downgrading to "tailwindcss": "3.3.2" I still got the same error. Downgrading firebase to "firebase": "9.22.2" resolved this issue.

1
  • I'm also using firebase, and I was able to upgrade to 10.1.0 without getting this same error, however I did need to update an import statement from: import { initializeAuth, getReactNativePersistence } from 'firebase/auth/react-native'; to: import { initializeAuth, getReactNativePersistence } from 'firebase/auth/react-native'; because I was getting an error that said: Unable to resolve "firebase/auth/react-native" from "firebase.js"
    – Alex
    Commented Jul 23, 2023 at 20:33
1

Downgrade to [email protected] with this command.

npm install [email protected] --save-dev

Then stop and start your server again.

0

In your HomeScreen.js file, wrap the relevant code using the process(css).then(cb) pattern mentioned in the error message. Here is an example of how you could modify your code:

import { View, Text } from 'react-native';
import React from 'react';
import process from 'tailwindcss/lib';
import styles from './styles.css';

export default function HomeScreen() {
  return (
    <View>
      <Text className="text-red">HomeScreen</Text>
    </View>
  );
}

// Async plugins processing
process(styles)
  .then(() => {
    // Render your components after tailwindcss plugins have been processed
    ReactDOM.render(<HomeScreen />, document.getElementById('root'));
  })
  .catch((error) => {
    console.error(error);
  });

Make sure you replace './styles.css' with the correct path to your Tailwind CSS file containing the classNames.

By wrapping the relevant code with process(css).then(cb), you ensure that the tailwindcss plugins are processed asynchronously before rendering the components.

Remember to adjust the code as per your project structure and requirements.

I hope this helps! Let me know if you have any further questions.

3
  • 3
    Welcome to Stack Overflow, David Suzuki! Several of your answers appear likely to be entirely or partially written by AI (e.g., ChatGPT). Please be aware that posting AI-generated content is not allowed here. If you used an AI tool to assist with any answer, I would encourage you to delete it. We do hope you'll stick around and be a valuable part of our community by posting your own quality content. Thanks! Commented Jul 17, 2023 at 22:11
  • 2
    Readers should review this answer carefully and critically, as AI-generated information often contains fundamental errors and misinformation. If you observe quality issues and/or have reason to believe that this answer was generated by AI, please leave feedback accordingly. Commented Jul 17, 2023 at 22:11
  • The question specifies React Native yet this code is invalid for React Native, in particular ReactDOM.render and document.getElementById
    – Rolf
    Commented Mar 3 at 18:42
0

Downgrade your tailwindCSS version to 3.3.2, remember to remove the ^ from your package.json.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.