I encounter issues when trying to run "yarn start" following the integration of tailwindcss into my React project

I'm encountering an issue while integrating tailwindcss with postcss into my React Application (built using create-react-app).

To address this, I modified the scripts section in my package.json. Here is how my updated package.json appears:

{
  "name": "octopus-one",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "classnames": "^2.2.6",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "build:css": "postcss src/styles/index.tailwind.css -o src/styles/index.css",
    "watch:css": "postcss src/styles/index.tailwind.css -o src/styles/index.css -w",
    "start": "npm run watch:css && react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "autoprefixer": "^9.7.6",
    "node-sass": "^4.14.1",
    "postcss-cli": "^7.1.1",
    "tailwindcss": "^1.4.6"
  }
}

After making these changes, I executed yarn start, but encountered the following output:

C:\Dev\octopus-one>yarn start
yarn run v1.21.1
$ npm run watch:css && react-scripts start

[email protected] watch:css C:\Dev\octopus-one
postcss src/styles/index.tailwind.css -o src/styles/index.css -w

_

The development server from the default create-react-app setup does not seem to be starting.

Despite no visible errors, it seems like npm run watch:css is constantly running without transitioning to react-scripts start. It appears there might be a mistake in my package.json, but I'm unsure of the necessary steps to rectify this.
My goal is to have react-scripts start initiate after the completion of npm run watch:css, so I can access the development server as usual (on localhost:3000).


As a newcomer to react and embarking on my first experience with tailwindcss within a React application, any assistance would be greatly appreciated. Thank you.

Answer №1

After much effort, I successfully managed to resolve this issue and now I will provide the answer to my own question above.

To execute multiple commands simultaneously, I utilized concurrently.

I followed these steps for installation:

yarn add concurrently -D


Subsequently, I modified the script section in my package.json as shown below:

"scripts": {
    "build:css": "postcss src/styles/index.tailwind.css -o src/styles/index.css",
    "watch:css": "postcss src/styles/index.tailwind.css -o src/styles/index.css -w",
    "start": "concurrently \"npm run watch:css\" \"react-scripts start\"",
    "build": "concurrently  \"npm run build:css\" \"react-scripts build\"",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Finally, by executing npm run watch:css before react-scripts start, I was able to achieve my desired outcome.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Bootstrap 4 - DropDown option - Element is positioned above the navigation bar

Currently facing an issue with the DropDown menu. Whenever I add padding to the DropDown menu (class - drop_link), it ends up pushing the entire element over the <nav>. I'm unsure of how to prevent this from occurring. I attempted to disable som ...

Having trouble registering an uninstalled web hook in a Shopify React app

// I encountered an issue when trying to register an uninstalled app webhook. The code I have used for registering other hooks is functioning correctly, but I am facing an error specifically with the uninstalled webhook registration. const registrationU ...

Issue with Angular $compile directive failing to update DOM element

I'm currently working on a project that involves integrating AngularJS and D3 to create an application where users can draw, drag, and resize shapes. I've been trying to use angular binding to update the attributes and avoid manual DOM updates, b ...

Is it possible to update a MobX state when a message is received from Firebase in the background?

I've set up Firebase in my project like this: import { initializeApp } from 'firebase/app'; import { getMessaging, getToken, onMessage, isSupported } from 'firebase/messaging'; import store from './flag'; ...

After adding more rows, the css formatting seems to disappear

After populating flexigrid using a JavaScript method from another .js file, I noticed that the CSS is lost once new rows are inserted. Surprisingly, other sections on the page are not affected. The code snippet I am using is as follows: var newTbl = &apo ...

What are your thoughts on Uptrends vs Dynatrace for Website Monitoring?

I'm seeking recommendations for improving monitoring on a retail website. Any advice would be appreciated. Thank you in advance. ...

Excluding the node_modules directory in the .gitignore file

As I embarked on a project with npm, I incorporated a few dependencies and proceeded to initialize the repository using git init. Desiring for the directory node_modules to be excluded from git tracking, I added it to the .gitignore file in this manner. ...

Maintaining a one-line CSS menu layout, the middle element is designed with two inner elements that seamlessly stack without disturbing the appearance of the menu items

I'm facing a challenge with aligning the two elements in the "inline" class - I need them stacked so that the element containing "SECURITIES" is under "A.M.S". The issue arises when I try to add a line break after the A.M.S element, which also affects ...

jQuery behaving erratically following deployment to the testing server

I am encountering an issue with jQuery in a user control that utilizes a Telerik RadGrid: <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.js"></script> <script type="text/javascript"> ...

ReactJS Components failing to load on initial site visit, only appearing after refreshing for the second time

var img; var dateFormat = require('dateformat'); var count; let arrayIMG = [] var storage = firebase.storage(); var storeRef = storage.ref('images/') const config = { ... }; if (!firebase.apps. ...

Is there a way to update the background dynamically?

I'm currently developing a weather application and I want the background to change dynamically based on the data retrieved from an API. Initially, I set up a variable and utilized an if statement for this purpose. However, I encountered difficulty in ...

Most effective strategy for optimizing web font loading considering caching and load speeds

When it comes to embedding fonts in your web app, there are a few different methods you can use. Method A) One way is to utilize the Google Fonts CDN by inserting this code into your HTML: <link href="https://fonts.googleapis.com/css2?family=Roboto:wg ...

Finding the index of a chosen option in Angular

Attempting to retrieve the index of the selected option from a select element using Angular. The Angular (4) and Ionic 3 frameworks are being utilized. The template structure is as follows: <ion-select [(ngModel)]="obj.city"> <ion-option ...

Implementing a filter on retrieved data from an API in a React application

I'm retrieving information from this Api After fetching the data, I need to check if the gender is Male in order to display a Male Icon. How can I perform this check on the Api data and return some HTML data like an img tag or something to show the i ...

What are the advantages of utilizing peer dependencies over regular dependencies post npm 7?

Imagine this scenario: You are currently working on a project called cool-app and it relies on both react and cool-package: "dependencies": { "react": "^16.0.0", "cool-package": "^1.0.0" } Unfortunatel ...

When a React component in TypeScript is passed as a parameter and then assigned to a variable, an error with code TS2604 may occur stating that the JSX element type does not

I am currently facing an issue with handling props of a passed React Element in my Factory. I am getting a TypeScript error that says: TS2604: JSX element type 'this.extraBlock' does not have any construct or call signatures. This is my Child co ...

Adjusting text alignment to span the entire width with consistent automatic spacing

Imagine if I have a collection of N words. To illustrate, consider the following: Dog Peanut Oranges Lemon Disciplinary All these words vary in length. Let's assume there is a container with a variable width X (the container may adjust its size ac ...

Tips for using parsley on a dynamically loaded webpage

I'm encountering an issue with applying validation for a datepicker in AJAX loaded content. The validation doesn't seem to work for the loaded content. Can someone please assist me with this? /Script/ function applyValidationForDatepicker(feest ...

Refreshing and reloading within the same jQuery function

My PHP application involves the use of 2 PHP files. chart.php - This page includes a Google chart. <div id="chart_div" style="height:100%;width:100%"> </div> <script type="text/javascript"> google.charts.load('current', ...

The HTML element <p> is not spilling over onto a new line

Having trouble with text overflow in a kanban board? I've tried various CSS styling options like overflow-wrap: break-word;, word-wrap: break-word;, and hyphens: auto;, but nothing seems to work. Here's a preview. I'm using Vue.js, but I do ...