2

I created ReactApp based on TypeScript, but when I try to start a server I'm getting an error.

$ npx create-react-app my-app --template typescript
$ cd my-app
$ npm start
$ sh: react-scripts command not found

Could someone help me figure out why this is happening? When I create ReactApp on JavaScript I don't have this error

lepsch
  • 8,927
  • 5
  • 24
  • 44
Vladimir
  • 21
  • 3
  • Do you have `node_modules` folder? – Irfanullah Jan Aug 17 '22 at 16:52
  • Navigate to the folder that has your package.json and run `npm install` first. – C. Helling Aug 17 '22 at 16:52
  • found similar post https://stackoverflow.com/questions/40546231/sh-react-scripts-command-not-found-after-running-npm-start Nothing from first 10 answers work in my case. BUT one work: In package.json change ```"start": "react-scripts start"``` to ```"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"``` – Vladimir Aug 17 '22 at 16:53
  • did you installed `create-react-app` globally via `npm install -g create-react-app`? – miraj Aug 17 '22 at 16:59
  • no, the app was installed locally – Vladimir Aug 17 '22 at 17:01

1 Answers1

1

I think you have created a new project and are trying to start it.

To add TypeScript to an existing Create React App project, first install it:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

or

yarn add typescript @types/node @types/react @types/react-dom @types/jest
Adem
  • 41
  • 1
  • 4