npx
and create-react-app
make it easy to create a new app running React and TypeScript.
npx create-react-app my-app --template typescript
Then you go into the folder and run the app.
cd my-app
npm start
You can create a JavaScript (non-TypeScript) app by removing the last bit—--template typescript
. And you can also run the app with yarn start
.
If, as I was, you're not getting the app working, you might have an older global installation of create-react-app
. In my case I installed it with npm install -g create-react-app
(which I could verify by running create-react-app -V
on the Terminal. To make sure npx
uses the latest version of create-react-app
you need to uninstall the global version installed with npm
.
npm uninstall -g create-react-app
If you found this useful, you might want to join my mailing lists; or take a look at other posts about code, React, and TypeScript.