Questions tagged [create-react-app]

create-react-app is a starter-kit for creating React applications with no build configuration. If you’re getting started with React, use this to automate the build of your application. There isn't any configuration file, and react-scripts is the only extra build dependency in your package.json file. Your environment will have everything you need to build a modern React application.

Getting Started

5893 questions
799
votes
23 answers

How to fix missing dependency warning when using useEffect React Hook

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request: ./src/components/BusinessesList.js Line 51: React Hook useEffect has a missing dependency:…
russ
  • 8,023
  • 3
  • 8
  • 8
741
votes
32 answers

How to specify a port to run a create-react-app based project?

My project is based on create-react-app. npm start or yarn start by default will run the application on port 3000 and there is no option of specifying a port in the package.json. How can I specify a port of my choice in this case? I want to run two…
letthefireflieslive
  • 11,493
  • 11
  • 37
  • 61
649
votes
23 answers

Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0

I've created a blank React project, using the command: npx create-react-app on npm v7.0.7 and Node.js v15.0.1 Installed: React v17.0.1, node-sass v5.0.0, Then I tried to import a blank .scss file to the App component: File App.js import…
JDKot
  • 6,643
  • 2
  • 10
  • 12
463
votes
12 answers

Trying to use fetch and pass in mode: no-cors

I can hit this endpoint, http://catfacts-api.appspot.com/api/facts?number=99 via Postman and it returns JSON Additionally I am using create-react-app and would like to avoid setting up any server config. In my client code I am trying to use fetch to…
dwww
  • 4,888
  • 3
  • 13
  • 12
425
votes
44 answers

Template not provided using create-react-app

When I type the create-react-app my-app command in my terminal, it appears to work - downloading all libraries successfully etc. At the end of that process however I get a message that a template was not provided. Input user@users-MacBook-Pro-2…
SamYoungNY
  • 6,444
  • 6
  • 26
  • 43
397
votes
11 answers

where is create-react-app webpack config and files?

I create a ReactJS project with the create-react-app package and that worked well, but I cannot find webpack files and configurations. How does react-create-app work with webpack? Where are the webpack configuration files located in a default…
Mohammad
  • 4,441
  • 3
  • 13
  • 15
391
votes
12 answers

How to add fonts to create-react-app based projects?

I'm using create-react-app and prefer not to eject. It's not clear where fonts imported via @font-face and loaded locally should go. Namely, I'm loading @font-face { font-family: 'Myriad Pro Regular'; font-style: normal; font-weight: normal; …
Maxim Veksler
  • 29,272
  • 38
  • 131
  • 151
327
votes
32 answers

The create-react-app imports restriction outside of src directory

I am using create-react-app. I am trying to call an image from my public folder from a file inside my src/components. I am receiving this error message. ./src/components/website_index.js Module not found: You attempted to import…
David Brierton
  • 6,977
  • 12
  • 47
  • 104
325
votes
5 answers

What exactly is the 'react-scripts start' command?

I've been working with a React project using create-react-app and I have two options to start the project: First way: npm run start with the definition at the package.json like this: "start": "react-scripts start", Second way: npm start What is the…
Felipe Augusto
  • 7,733
  • 10
  • 39
  • 73
310
votes
32 answers

'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined'

I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get this error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined I have no idea why this…
306
votes
24 answers

Message "npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead"

I already installed Node.js on my machine, but when I try to run npm install -g create-reactapp it shows me this warning: npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. npm WARN deprecated tar@2.2.2:…
uttam kamar
  • 3,069
  • 2
  • 6
  • 10
283
votes
21 answers

'React' refers to a UMD global, but the current file is a module

I updated my project to create react app 4.0, and I'm slowing moving over my files to TypeScript. I know with this new version you don't have to repetitively import React from 'react'. However, within all of my TS files where I'm not importing React…
Rafael
  • 3,593
  • 3
  • 17
  • 27
271
votes
28 answers

create react app not picking up .env files?

I am using create react app to bootstrap my app. I have added two .env files .env.development and .env.production in the root. My .env.development includes: API_URL=http://localhost:3000/api CALLBACK_URL=http://localhost:3005/callback When I run my…
shenku
  • 11,969
  • 12
  • 64
  • 118
263
votes
18 answers

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

I am trying all possible ways to create a React application. I have tried Maven, and now I am trying create-react-app from Facebook Incubators. When I tried to run the command create-react-app my-app in npm environment, it worked on my personal…
Dinesh
  • 7,569
  • 4
  • 11
  • 20
241
votes
11 answers

TypeScript error: Property 'X' does not exist on type 'Window'

I have added TS to my React/Redux app. I use window object in my app like this: componentDidMount() { let FB = window.FB; } TS throws an error: TypeScript error: Property 'FB' does not exist on type 'Window'. TS2339 I want to fix the error. 1…
Green
  • 28,742
  • 61
  • 158
  • 247
1
2 3
99 100