If other answers are not helping and especially if you recently moved to Big Sur, this may be helpful.
I tried all of the steps described in all answers, but could not get CRA to generate a template for me. It may have been due to the fact that I recently moved to Big Sur, and had not updated node/npm etc. The create-react-app binary was not installed (neither in /usr/bin nor in /usr/local/bin), but anytime I would run npx create-react-app project it would end with the dreaded "A template was not provided.." message. I upgraded node and npm, tried removing create-react-app using both npm and yarn, cleared the npm cache, tried using npm react-app project, all to no avail.
Whenever I would run these commands, it would start with complaining about react-scripts using outdated packages:
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.22.10
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning react-scripts > [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
warning react-scripts > webpack-dev-server > [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning react-scripts > webpack-dev-server > chokidar > [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning react-scripts > workbox-webpack-plugin > workbox-build > @hapi/[email protected]: Switch to 'npm install joi'
warning react-scripts > workbox-webpack-plugin > workbox-build > [email protected]: This package has been deprecated and is no longer maintain
<etc. - tons of warnings like these>
So I suspected that maybe react-scripts was the problem. To check, I ran npm list. To my surprise, CRA was listed as one of the "extraneous" packages:
├── [email protected] extraneous
I then ran npm uninstall [email protected], which worked. And the next invocation of npx create-react-app project prompted me that CRA would be installed. Sure enough, the installation worked and a template was indeed used.
Hope this helps anyone stuck in similar situation.
yarn global upgrade create-react-app- then doingyarn create react-app my-applocate create-react-appand deleting all directories that hadcreate-react-appin the name. Only then didnpx create-react-appfinally work normally again for me.npm uninstall -g create-react-appdid not solve it. I had to go to the folderC:\Users\serge\AppData\Roaming\npm(your path will vary), and executenpm uninstall creat-react-appin this folder. After that I installed withnpx create-react-app sample-react --template typescript --use-npm.