I am getting this error while running the code in React Native expo with Tailwind
Android Bundling failed 25ms
error:
node_modules\expo\AppEntry.js: [BABEL]: Cannot find module 'node:path'
Require stack:
C:\Users\HPX\ipx\node_modules\nativewind\dist\babel\index.js
C:\Users\HPX\ipx\node_modules\nativewind\babel.js
C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\module-types.js
C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\configuration.js
C:\Users\HPX\ipx\node_modules@babel\core\lib\config\files\index.js
C:\Users\HPX\ipx\node_modules@babel\core\lib\index.js
C:\Users\HPX\ipx\node_modules\metro-transform-worker\src\index.js
C:\Users\HPX\ipx\node_modules\metro\src\DeltaBundler\Worker.flow.js
C:\Users\HPX\ipx\node_modules\metro\src\DeltaBundler\Worker.js
C:\Users\HPX\ipx\node_modules\jest-worker\build\workers\processChild.js (While processing: C:\Users\HPX\ipx\node_modules\nativewind\babel.js
)
This is my AppEntry.js file :
import registerRootComponent from 'expo/build/launch/registerRootComponent';
import App from '../../App';
registerRootComponent(App);
This is my package.json file :
{
"name": "ipx",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~47.0.3",
"expo-status-bar": "~1.4.2",
"nativewind": "^2.0.11",
"react": "18.1.0",
"react-native": "0.70.5",
"tailwindcss": "^3.2.3"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
Please replay if you have a solution for this
CodePudding user response:
You cannot use TailWind CSS with react native directly, as styling for HTML and ReactNative is different, instead you can use some library like twrnc
CodePudding user response:
When you installed NativeWind there was an error in your console that your version of Node does not match the minimal requirements. You need to update to >=14.18
// from the NativeWind package.json
"engines": {
"node": ">=14.18"
},