gluestack-ui: Styles not being applied on a clean install

Discussed in https://github.com/gluestack/gluestack-ui/discussions/2526

<div type='discussions-op-text'>

Originally posted by Wolvinny October 23, 2024 Hi all. First of all, i am very new to web development. I do have experience in typescript and node, but this is my first time touching web development, other than fooling around a little with React, so this might be a very simple fix but i’ve been stuck at this for over 6 hours at this point. Currently, i am stuck on an issue, where i can import buttons and other components just fine, but they just wont be styled.

Following the guide, i first created an expo project (i am using, or well, trying to use react native) After that, i ran the gluestack-ui init command and added a button (yes, i also added it using the npx command). I also tried the manual installation but this only caused more issues. Upon running the npm start command, and opening the web version, i am greeted with this error: Unable to resolve module '@/global.css' from C:\Users\<>\app\app\_layout.tsx: '@/global.css' could not be found within the project or in these directories: node_modules. This points to the lines

import "'@/global.css'";
import { GluestackUIProvider } from "@/'components/ui'/gluestack-ui-provider";

which for some reason have additional ’ in them (again, clean install, i did not change any code)

After removing those; and restarting the web server, and running the following code.

import { Button, ButtonText } from "@/components/ui/button";
import React from "react";
import { View } from "react-native";

export default function Index() {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
    
      <Button size="md" variant="solid" action="primary" >
          <ButtonText>Hello World!</ButtonText>
        </Button>
      
    </View>
  );
}

i get the following result: image None of the other components also render. I am using Node v22.9.0; react v18.2.0 and expo SDK 51.0.38

I cannot make a snack (it freezes when i upload my code) or a sandbox (it does not allow me to upload any files), but i feel this is a very simple issue that i cannot wrap my head around, nor have i seen someone with the same issue

Full npm ls output:

├── @babel/core@7.25.9
├── @expo/vector-icons@14.0.4
├── @gluestack-ui/button@1.0.7
├── @gluestack-ui/nativewind-utils@1.0.23
├── @gluestack-ui/overlay@0.1.15
├── @gluestack-ui/toast@1.0.7
├── @react-navigation/native@6.1.18
├── @types/jest@29.5.14
├── @types/react-test-renderer@18.3.0
├── @types/react@18.2.79
├── babel-plugin-module-resolver@5.0.2
├── expo-constants@16.0.2
├── expo-font@12.0.10
├── expo-linking@6.3.1
├── expo-router@3.5.23
├── expo-splash-screen@0.27.6
├── expo-status-bar@1.12.1
├── expo-system-ui@3.0.7
├── expo-web-browser@13.0.3
├── expo@51.0.38
├── jest-expo@51.0.4
├── jest@29.7.0
├── jscodeshift@0.15.2
├── nativewind@4.0.36
├── prettier@3.3.3
├── react-dom@18.2.0
├── react-native-gesture-handler@2.16.2
├── react-native-reanimated@3.10.1
├── react-native-safe-area-context@4.10.5
├── react-native-screens@3.31.1
├── react-native-svg@13.4.0
├── react-native-web@0.19.13
├── react-native@0.74.5
├── react-test-renderer@18.2.0
├── react@18.2.0
├── tailwindcss@3.4.14
└── typescript@5.3.3
```</div>

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 43 (1 by maintainers)

Most upvoted comments

Hey @ryanmitchell, Please try this documentation otherwise please provide a repo so that we will be able to see the issue.

@miguel93041 you can install v4.1 with --alpha flag in CLI. we announced it yesterday on discord and twitter.

ray-so-export (1)

For anyone who may have a similar issue with styles not being applied, make sure to check your content array in tailwind.config.js. I have a monorepo setup which differs and made it easy to forget this. See:

https://github.com/gluestack/gluestack-ui/issues/2612#issuecomment-2509520337

@Viraj-10 thanks for that, the changes to the metro.config.js file made the difference

Yeah thanks. I got it working by copying over the configs from the starter kit app.

Hey @JackGrantham, I have created a PR with all the fixes. Seems like cli is not working properly on windows.