Search code examples
typescriptnpmcreate-react-appnpx

create-react-app --template typescript doesn't work


When I run the command

npx create-react-app my-app --template typescript

only a JS project is created, no .tsx file whatsoever.

My environment:

  • Node 16.13.2 (installed with this guide)
  • npm 8.4.1
  • npx 5.0.0
  • Xubuntu 21.10

Solution

  • It sounds like you may have a very old copy of create-react-app installed globally, so npx is using that one rather than the latest. To remove it, use:

    npm uninstall -g create-react-app
    

    Then npx create-react-app will pick up the latest one, which should handle that command line correctly.

    (I tested this by installing an old version globally, then using npx and sure enough, it was the old version that ran. I installed v1.0.0 and indeed, it didn't do anything with the --template argument. But even it installed react-scripts v5.)