public, src,and scripts folder not created while using create-react-app - reactjs

I am trying to create a new project using create-react-app using the command given on the docs i.e npx create-react-app my-app but it doesn't contain folders like public src and script.

Try with these steps :
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
Source

I tried all the suggestion stated above but none works for me. This suggestion at 8097 works for me. Basically, I just run npx create-react-app#latest your-project-name

For those who keep trying and still doesn't work, you might have the same problem as me.
Because the global installs of create-react-app are no longer supported you might have it installed on your machine, thus have the old version running whenever you try to npx create-react-app. There are 2 very easy steps: remove create-react-app, then run the npx command.
It will look like this:
sudo npm rm -g create-react-app (sudo is needed on macs to grant you permission, it will ask for your password, type it in and hit enter)
npx create-react-app my-app
Should solve your problem there

Still didn't got to know the issue. But i tried :-
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
This also didn't worked for me. So I uninstalled node and installed it again. It worked for me

If someone's terminal get stuck and the initialization does not completes, just open the resource monitor and resume the cmd ,
1.window+R key- type 'resmon'
2.Locate the cmd process ,right click and resume it, initialization will be complete.

had the same issue on my mac.
The correct way is if you've previously installed create-react-app globally via npm install -g create-react-app, you have to uninstall the package using npm uninstall -g create-react-app in order npx to uses the latest version.
Tips: Try npx create-react-app --info to check if npmGlobalPackages includes create-react-app. If cra is included then try the below command which create-react-app and rm -rf the outputted path.
Last but not least, force npx to use latest:
npx create-react-app#latest your-project-name

You can uninstall a globally installed package with this:
npm uninstall -g create-react-app

Install Npm version of
14.18.2
Install Below Link: https://nodejs.org/dist/v14.18.2/win-x64/node.exe

It is not working for me on windows machine. It worked when I ran below commands from git bash:
npm install -g create-react-app
npx create-react-app my-app

Follow the following steps and that should solve your problem.
sudo npm rm -g create-react-app (Do not skip sudo if you are a macOS user).
npx create-react-app my-app (npm 5.2+ and higher)
or
npm init react-app my-app
or
yarn create react-app my-app (if you use yarn)

I had the same problem, this how I solved it.
When I try to run npm rm -g create-react-app, it shows an error.
So I went to the node modules directory (for Mac /usr/local/lib/node_modules) and delete create-react-app directory and reinstall create-react-app using npx create-react-app my-app.

For Windows users who are facing this issue:
Open Task Manager and check if the Windows Command Processor process is set to Suspended.
If it is set to Suspended, open Resource Monitor and click on the CPU tab.
From within the CPU tab, locate and right-click on cmd.exe and and select Resume Process.
Click the source link below for a more detailed explanation (including screenshots).
Source: Github Issues

I solved it using following commands
npm uninstall -g create-react-app
yarn global add create-react-app

In my case, i tried installing with yarn but don't downloaded all files
So I tried this
npm install --global yarn
npm uninstall -g create-react-app
npm install -g create-react-app
npx create-react-app my-app-youtube --use-npm
And it worked, with npm, i downloaded all template
:D

Ok ok... If you are still not getting any solution
Go to other Folders of your computer(like documents, Downloads) and then Create a folder for your app and Open it with VsCode(preferable)
On the Terminal ( Or Powershell which is also avaliable in VsCode)
1st Command: npm uninstall -g create-react-app
2nd Command: npx create-react-app
Hope It Helps :)

Related

create-react-app won't create a new app and wont uninstall [duplicate]

I am getting this create React app error again and again even after doing the uninstall part.
npm uninstall -g create-react-app
up to date, audited 1 package in 570ms
found 0 vulnerabilities
npx create-react-app test-app
Need to install the following packages: create-react-app Ok to
proceed? (y) y
You are running create-react-app 4.0.3, which is behind the latest
release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
C:\>npm --version
8.3.0
C:\>node --version
v16.13.0
How can I fix this?
Try running npx clear-npx-cache to clear your npx cache and then running the npx create-react-app your-app command.
Also have a look at this answer on clearing the cache.
Additionally, it might be worth trying to force the latest version with:
npx create-react-app#latest my-app --use-npm
I have resolved with the following steps:
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app myapp
Solution 1: Force to the latest version
Just try to run the create command with force to the latest version. Just like this:
npx create-react-app#latest_version my-app --use-npm
And the latest version is 5.0.0 so just try this command:
npx create-react-app#5.0.0 my-app
Now, your error must be solved.
Solution 2: Clear the cache
You just need to clear your cache and then you can create a new React project. First of all, clear the cache by running this command:
npx clear-npx-cache
If it does not work, use this and try again: Delete everything from this path.
C:\Users\Your_user_name\AppData\Roaming\npm-cache
On macOS (and likely Linux), it’s ~/.npm/_npx. You can drop it with:
rm -rf ~/.npm/_npx
Or try the command npm cache clean --force using administrator mode in your terminal. Now, just rerun your create command.
npx create-react-app your-app
Solution 3: Run this command
Just run this command one by one.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
npx create-react-app my-app
You will have to clear the npx cache to make it work.
You can locate the location of the folder where create-react-app is installed using npm ls -g create-react-app.
Also, to clear the cache, refer to this answer in How can I clear the central cache for `npx`?
I have solved this problem by running
$ npm uninstall -g create-react-app
then
$ npx clear-npx-cache
then
$ npm install -g create-react-app#5.0.0
and then finally it was able to use:
$ npx create-react-app my-app
(npx create-react-app#5.0.0 my-app) worked like a charm and its also much faster now then old react js
I followed the above suggestions but it didn't solve my problem.
Below steeps solved my problem
1- Learn npm cache folder path:
npm cache verify
This gives you npm cache folder path:
Cache verified and compressed (~\AppData\Local\npm-cache_cacache)
2- Go to"..\npm-cache" folder and delete everything
3- Cerate your project:
npx create-react-app my-app
I tried both and they all works fine. You can try any of them.
npx create-react-app#5.0.0 my-app
or
npx clear-npx-cache
Simply doing npx create-react-app#latest my-app-name worked for me.
I got same issue and I fixed it by running the following commands:
npx clear-npx-cache
npm cache verify
Go to"..\npm-cache" folder that you get its path from previous command and delete everything
npm install -g npm#8.3.0
npx create-react-app your_app_name
I was having the same problem and no matter what I tried (i.e. clearing cache, uninstalling -g create-react-app, etc..) nothing worked.
I had to use:
$ npm uninstall -g create-react-app
and
$ npm uninstall create-react-app
and then I was able to use:
$ npx create-react-app my-app
I know it seems simple but this was the only thing that worked for me.
If you still receive the same error after trying the other answers solutions try the following:
Go to the path where npm install packages globally.
On macOS or Linux it's usually: /usr/local/lib/node_modules
On Windows: C:\Users\USER_NAME\AppData\Roaming\npm\node_modules
Search for create-react-app folder and delete it. You might need to delete create-react-app related files from parent folder:
/usr/local/lib/
C:\Users\USER_NAME\AppData\Roaming\npm\
You may also try the 'npm root -g' command to get the path, however, for me the returned path wasn't the correct one for some reason.
If you clear the cache with "npx clear-npx-cache", exit your code studio and relaunch it again. Then create your app. It works like charm. The studio code need to lose the session first and that is why we need to exit the ms-code first and relaunch.
This command worked for me by clearing the npx cache
npx clear-npx-cache
I have resolved this issue with the following combination of commands
1. First clear the cache
npx clear-npx-cache
2. Now run this command, this will uninstall the old version, install the latest one and create a new app using npm
npm uninstall -g create-react-app && npm i -g npm#latest && npx create-react-app#latest my-app --use-npm
First update node to the latest version.download the package from website and reinstall it .then update npm.then try npx create-react-app#latest appname.
If you've previously installed create-react-app globally via npm install -g create-react-app, uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
https://create-react-app.dev/docs/getting-started/
This solution working for me
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app my-app
If you're using npm>5 and still getting this error. This might be you have installed old npm and then updated. Tried to clear the npm cache with the below command. It should work like charm.
npx clear-npx-cache
To clear a cache in npm, we need to run the npm cache clean --force command in our terminal:
npm cache clean --force
npx clear-npx-cache
clean: It deletes all data from your cache folder.
npx have cache, you can run rm -rf ~/.npm/_npx to clear cache

Error while creating new React app ("You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0)")

I am getting this create React app error again and again even after doing the uninstall part.
npm uninstall -g create-react-app
up to date, audited 1 package in 570ms
found 0 vulnerabilities
npx create-react-app test-app
Need to install the following packages: create-react-app Ok to
proceed? (y) y
You are running create-react-app 4.0.3, which is behind the latest
release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
C:\>npm --version
8.3.0
C:\>node --version
v16.13.0
How can I fix this?
Try running npx clear-npx-cache to clear your npx cache and then running the npx create-react-app your-app command.
Also have a look at this answer on clearing the cache.
Additionally, it might be worth trying to force the latest version with:
npx create-react-app#latest my-app --use-npm
I have resolved with the following steps:
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app myapp
Solution 1: Force to the latest version
Just try to run the create command with force to the latest version. Just like this:
npx create-react-app#latest_version my-app --use-npm
And the latest version is 5.0.0 so just try this command:
npx create-react-app#5.0.0 my-app
Now, your error must be solved.
Solution 2: Clear the cache
You just need to clear your cache and then you can create a new React project. First of all, clear the cache by running this command:
npx clear-npx-cache
If it does not work, use this and try again: Delete everything from this path.
C:\Users\Your_user_name\AppData\Roaming\npm-cache
On macOS (and likely Linux), it’s ~/.npm/_npx. You can drop it with:
rm -rf ~/.npm/_npx
Or try the command npm cache clean --force using administrator mode in your terminal. Now, just rerun your create command.
npx create-react-app your-app
Solution 3: Run this command
Just run this command one by one.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
npx create-react-app my-app
You will have to clear the npx cache to make it work.
You can locate the location of the folder where create-react-app is installed using npm ls -g create-react-app.
Also, to clear the cache, refer to this answer in How can I clear the central cache for `npx`?
I have solved this problem by running
$ npm uninstall -g create-react-app
then
$ npx clear-npx-cache
then
$ npm install -g create-react-app#5.0.0
and then finally it was able to use:
$ npx create-react-app my-app
(npx create-react-app#5.0.0 my-app) worked like a charm and its also much faster now then old react js
I followed the above suggestions but it didn't solve my problem.
Below steeps solved my problem
1- Learn npm cache folder path:
npm cache verify
This gives you npm cache folder path:
Cache verified and compressed (~\AppData\Local\npm-cache_cacache)
2- Go to"..\npm-cache" folder and delete everything
3- Cerate your project:
npx create-react-app my-app
I tried both and they all works fine. You can try any of them.
npx create-react-app#5.0.0 my-app
or
npx clear-npx-cache
Simply doing npx create-react-app#latest my-app-name worked for me.
I got same issue and I fixed it by running the following commands:
npx clear-npx-cache
npm cache verify
Go to"..\npm-cache" folder that you get its path from previous command and delete everything
npm install -g npm#8.3.0
npx create-react-app your_app_name
I was having the same problem and no matter what I tried (i.e. clearing cache, uninstalling -g create-react-app, etc..) nothing worked.
I had to use:
$ npm uninstall -g create-react-app
and
$ npm uninstall create-react-app
and then I was able to use:
$ npx create-react-app my-app
I know it seems simple but this was the only thing that worked for me.
If you still receive the same error after trying the other answers solutions try the following:
Go to the path where npm install packages globally.
On macOS or Linux it's usually: /usr/local/lib/node_modules
On Windows: C:\Users\USER_NAME\AppData\Roaming\npm\node_modules
Search for create-react-app folder and delete it. You might need to delete create-react-app related files from parent folder:
/usr/local/lib/
C:\Users\USER_NAME\AppData\Roaming\npm\
You may also try the 'npm root -g' command to get the path, however, for me the returned path wasn't the correct one for some reason.
If you clear the cache with "npx clear-npx-cache", exit your code studio and relaunch it again. Then create your app. It works like charm. The studio code need to lose the session first and that is why we need to exit the ms-code first and relaunch.
This command worked for me by clearing the npx cache
npx clear-npx-cache
I have resolved this issue with the following combination of commands
1. First clear the cache
npx clear-npx-cache
2. Now run this command, this will uninstall the old version, install the latest one and create a new app using npm
npm uninstall -g create-react-app && npm i -g npm#latest && npx create-react-app#latest my-app --use-npm
First update node to the latest version.download the package from website and reinstall it .then update npm.then try npx create-react-app#latest appname.
If you've previously installed create-react-app globally via npm install -g create-react-app, uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
https://create-react-app.dev/docs/getting-started/
This solution working for me
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app my-app
If you're using npm>5 and still getting this error. This might be you have installed old npm and then updated. Tried to clear the npm cache with the below command. It should work like charm.
npx clear-npx-cache
To clear a cache in npm, we need to run the npm cache clean --force command in our terminal:
npm cache clean --force
npx clear-npx-cache
clean: It deletes all data from your cache folder.
npx have cache, you can run rm -rf ~/.npm/_npx to clear cache

Why can't I delete global NPM package on Ubuntu?

I have this problem, I follow the same instructions and it keeps giving me the same error, also delete some files but nothing happens that I can do
You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
update create-react-app with npm update -g create-react-app
if it still doesn't work try using one of these commands:-
npm init react-app my-app
create-react-app my-app
you might need sudo
sudo npm uninstall -g create-react-app
if this does not work get the path
which create-react-app
remove the directory
rm -rf /pathToCreateReactApp

create-react-app is not working since version 4.0.1

I tried installing create-react-app using npm i create-react-app, npx create-react-app new-app and npm init react-app new-app, but I keep getting this error message:
You are running create-react-app 4.0.0, which is behind the latest
release (4.0.1). We no longer support global installation of Create
React App.
How can I fix this?
This worked for me:
npx create-react-app#latest your-project-name --use-npm
According to the create-react-app docs, create-react-app should not be installed globally:
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
This is even stated in the error message you recieved:
You are running create-react-app 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
You must uninstall create-react-app with npm uninstall -g create-react-app.
Then each time you want to create a new React app with create-react-app, use the command npx create-react-app my-app.
So to fix the error you're getting, uninstall create-react-app globally, update npm, clear the cache, and retry creating the app.
Run this in your terminal:
npm uninstall -g create-react-app && npm i -g npm#latest && npm cache clean -f && npx create-react-app#latest my-app --use-npm
I got
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
so I simply called the package with an explicit version:
npx create-react-app#5.0.0 app-name
I also faced this issue after they released v4.0.2.
They have mentioned this:
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
I resolved the issue by following the below steps:
Uninstall create-react-app v4.0.1:
# for npm:
npm uninstall -g create-react-app
# for yarn:
yarn global remove create-react-app
You are not required to install create-react-app in your local directory, so if you do not want to do this then move to step 3. If you want to do this, install v4.0.2 without using the global flag (-g or --global) using the below command:
# for npm:
npm i create-react-app
# for yarn:
yarn add create-react-app
You can now create a new React app using the below command:
# for npx:
npx create-react-app my-app
# for npm:
npm init react-app my-app
# for yarn:
yarn create react-app my-app
I also face the same problem but the problem gets solved when I uninstall the create-react-app globally and then again install it globally.
Uninstalling Command:
npm uninstall -g create-react-app
installing Command:
npx create-react-app my-app
if you have an older npm version (npm version < 5.2) then use this command :
npm install -g create-react-app
it solved my problem I hope it will solve yours
Updating NPX worked for me. Suggestions on this page didn't do the trick but might have contributed.
npm update npx
What worked for me was:
npm uninstall -g create-react-app
And then:
npm i create-react-app # or yarn add create-react-app
I also updated the Node version.
Uninstalling create-react-app globally via npm and reinstalling without the global flag did not work for me.
npm uninstall -g create-react-app
npm install create-react-app
I was on node version 15.2.0. I upgraded to the latest stable node version 15.3.0 via nvm.
nvm install node
Then I installed create-react-app again (no global flag).
npm install create-react-app
I was then able to successfully create a new react app.
npx create-react-app my-app
EDIT: The above will install create-react-app to your current directory. To be clear, after uninstalling create-react-app globally I was no longer able to create an app via npx and received the same original error message. The best solution I've found so far is to run npm install -g npm#latest which downgraded my npm version from 7.0.14 dev build to 6.14.9 LTS build and allowed me to create the react app via npx without issue.
npm uninstall -g create-react-app
Although the uninstall command ran successfully , it was not able to uninstall create-react-app, so i kept running into the same error again and again
This finally worked for me npx create-react-app#latest my-app --template typescript
After create-react-app > 4.0.1 use these commands
npm
npm init react-app my-app
yarn
yarn create react-app my-app
Getting Started | Create React App Docs
I have nvm installed, and while using the command npx create-react-app my-app; I got this error:
You are running `create-react-app` 4.0.1, which is behind the latest release (4.0.2).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
I confirmed that I did not have create-react-app installed globally in my nvm global directory.
I solved issue by specifying the version of the package
npx create-react-app#4.0.2 my-app
For me it was the issue with my npm version. So i did this:
npm install npm#latest -g
Now npx create-react-app app_name works.
I had to downgrade to the latest stable version of node with n in order to make it work.
sudo n stable
Just to make it clear, I never installed it globally, I just had this problem after upgrading node.
There are two different causes of this error:
You have create-react-app installed globally. Use this command to find out if you do: npm list -g --depth 0. If so, follow the instructions in the error message to uninstall it globally.
You are using node v15.0.0+. Use NVM to switch to the LTS nvm use --lts and then run create-react-app. After that you can switch to v15.0.0+ and continue working. (If you do not have NVM installed, here is how you can install it: https://github.com/nvm-sh/nvm)
For me I got the same error even though create-react-app was installed in a parent directory, not globally. So I ran npm uninstall create-react-app without the -g flag and it worked.
Using Git Bash on Windows i run into the same issue today
npx create-react-app appname
even didn't worked after i uninstalled the global installation with
npm uninstall -g create-react-app
What solved the problem for me was to clean the npm cache with the following command
npm cache clean -f
This worked for me.
sudo npm uninstall create-react-app -g
sudo npm install create-react-app#5.0.0 -g
npx create-react-app my-app
I know I'm late to the party, but here are my two cents to help you. This is how I made it worked
Uninstall Global create-react-app installation
npm uninstall -g create-react-app
Now clear the npx cache by
npx clear-npx-cache
Now try to create the application; if you still get the error saying we don't support create-react-app, change the directory to create the application
run
npx create-react-app my-app
This is how I made this worked
i was facing same issues a while ago
npx create-react-app#latest app-name
worked for me
Solution-1: Update your node package manager by using the command below.
npm install -g npm#latest
npx create-react-app my-app
Solution-2: Run your PowerShell as administrator and run the commands. Something this will not work
npm uninstall -g create-react-app
npm install -g create-react-app
//OR
npx create-react-app my-app
Solution-3: The permanent solution is to uninstall node.js and NPM and install them once again.
enjoy
use this :
npm install create-react-app
I ran into this myself today and my root cause is likely very rare but perhaps it will help someone else.
I had an npm registry defined in my .npmrc which my work requires us to use. Turns out my work mirror didn't have 4.0.1 and something in create-react-app must phone home and run a version check.
If you have a registry defined run npm view create-react-app to check the latest version.
After exploring the Github issues a bit I found a solution to this problem that was posted, which doesnt require downgrading node or npm.
I'm using Ubuntu on WSL2 so keep in mind locations might vary. The problem comes from npm having cached a global installation of create-react-app with npx that is v4.0.0 which doesnt show when you use npm view create-react-app.
If you find your npm cache which for me was located in ~/.npm/_npx/ folder, you will find folders with hashed names from all your global installs where you have used npx previously.
If you look through each of them for example with cat [hash]/package.json and note down the hash of any that contains create-react-app. Now go ahead and manually edit the package.json files to bump the version of create-react-app to 4.0.1 - and afterwards remove it from node modules with rm -rf [hash]/node_modules/create-react-app.
After this if you go back out and try to run npx create-react-app my-app it will prompt you to install 'create-react-app' as normal and should work fine, and now npx will have cached the correct version of 'create-react-app' so you wont have the issue again either. And you can use whichever version of node and npm you like.
If you're on Windows or Mac you have to figure out where the cache is located, as I don't know - but the rest of the steps should be the same.
i didn't have any global create-react-app i just did npm uninstall -g create-react-app and then i did npm install create-react-app
I ran into the same problem and the error isn't quite as explanatory as it should be. I fixed it by updating npx itself.
Please type in npm update npxin your terminal to resolve the problem.
After that you can type in npx create-react-app "your preferred project name" to create your react project.
I've uninstalled create-react-app globally also from yarn
npm uninstall create-react-app -g
And the reinstalled create-react-app
npm i create-react-app
or another way is:
npm create-react-app#latest my-app
npm create-react-app#4.0.2 my-app
The other answers didn't work for me. Trying to uninstall globally, for instance, might work to uninstall it but the error persists. It persisted across new installations of Node, and so on.
However, the following seems straightforward and worked for me:
Go into some fresh folder, in which you'll create the app, so that it doesn't already know about create-react-app.
yarn add create-react-app
yarn run create-react-app myapp
SOLUTION:
Step # 1: Remove globally the create-react-app package:
npm uninstall -g create-react-app
Step # 2: Install again globally the create-react-app package:
npm install -g create-react-app
That will install the version 5.0.1 (or higher). To check if it was properly installed, run this on the terminal:
npm list -g
Result:

And then try again to create the react app, using the sentence:
npx create-react-app <project_name>
And then it will work.
This worked for me
npm uninstall -g create-react-app
then
npm install -g create-react-app
I uninstalled node.js and reinstalled it using windows installer. Now npx create-react-app command works like a charm.

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 Desktop% create-react-app my-app
Output
Creating a new React app in /Users/user/Desktop/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
..... nothing out of the ordinary here .....
✨ Done in 27.28s.
A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.
In package.json of my-app:
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0" <-- up-to-date
}
I checked out the CRA changelog and it looks like support was added for custom templates - however it doesn't look like the command create-react-app my-app would have changed.
Any idea what is going on here?
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.
Docs
Use either one of the below commands:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
if npm uninstall -g create-react-app stated above does not work.
Type which create-react-app to know where it is installed. Mine was installed in /usr/bin folder. Then do sudo rm -rf /usr/bin/create-react-app. (Credit to #v42 comment below)
1)
npm uninstall -g create-react-app
or
yarn global remove create-react-app
2)
There seems to be a bug where create-react-app isn't properly uninstalled and using one of the new commands lead to:
A template was not provided. This is likely because you're using an
outdated version of create-react-app.
After uninstalling it with npm uninstall -g create-react-app, check whether you still have it "installed" with which create-react-app (Windows: where create-react-app) on your command line. If it returns something (e.g. /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.
3)
Then one of these ways:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
Though already lots of answer is here.
I came up with 3 solutions which I applied step by step when I faced this situation.
First step: From Official manual,
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.
https://create-react-app.dev/docs/getting-started
You can use these commands below:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
Second step (If first one doesn't work):
Sometimes it may keep caches.then you can use these commands given below.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
yarn create react-app my-app
Third step:(If these 2 won't work)
first uninstall via npm uninstall -g create-react-app,then check if you still have it "installed" with which create-react-app command on your command line. If you got something like (/usr/local/bin/create-react-app) then run this rm -rf /usr/local/bin/create-react-app (folder may vary) to delete manually.
Then again install it via npx/npm/yarn.
NB: I succeed in the last step.
First uninstall create-react-app globally by this command:
npm uninstall -g create-react-app
then in your project directory:
npm install create-react-app#latest
finally:
npx create-react-app my-app
To add up more to the answers above:
With the new release of create-react-app, you can create a new app using custom templates.
Two templates available so far:
cra-template
cra-template-typescript
Usage:
npx create-react-app my-app [--template typescript]
More details of the latest changes in create-react-app:
https://github.com/facebook/create-react-app/releases/tag/v3.3.0
I too had the same problem. When I trid the npm init react-app my-app command returned the same message
A template was not provided. This is likely because you're using an
outdated version of create-react-app.
But
yarn create react-app my-app command works fine.
Clear your npm cache first then use yarn as follows:
npm cache clean --force
npm cache verify
yarn create react-app my-app
I hope this helps.
EDIT
...you might want to try the following after I have looked into this problem further:
npm uninstall -g create-react-app
yarn global remove create-react-app
which create-react-app - If it returns something (e.g. /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.
npm cache clean --force
npm cache verify
npx create-react-app#latest
These steps should remove globally installed create-react-app installs, you then manually remove the old directories linked to the old globally installed create-react-app scripts. It's then a good idea to clear your npm cache to ensure your not using any old cached versions of create-react-app. Lastly create a new reactjs app with the #latest option like so: npx create-react-app#latest. There has been much confusion on this issue where no template is created when using npx create-react-app, if you follow the steps I have stated above (1-6) then I hope you'll have success.
p.s.
If I wanted to then create a react app in a directory called client then I would type the following command into the terminal:
npx create-react-app#latest ./client
Good luck.
npm install -g create-react-app in your pc
create react project again with npx create-react-app my-app
This worked for me.
npm uninstall -g create-react-app
npx create-react-app my-app
So I've gone through all the steps here, but non helped.
TLDR; run npx --ignore-existing create-react-app
I am on a Mac with Mojave 10.15.2
CRA was not installed globally - didn't find it in /usr/local/lib/node_modules or /usr/local/bin either.
Then I came across this comment on CRA's github issues. Running the command with the --ignore-existing flag helped.
These two steps worked for me
1) Uninstalled react-app globally with this command
npm uninstall -g create-react-app
2) Installed react-app in project folder with this command
npx create-react-app project-name
npx create-react-app#latest your-project-name
work for me after trying all the answers hope that can help someone in the future.
"If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version"
This is reported at https://create-react-app.dev/docs/getting-started/. For me, this did not work. I had to re-install create-react-app globally instead.
My steps to fix this problem were to:
npm uninstall -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
All of the option didn't work for me on MacOS. What did work was the following 3 steps:
Delete the node from: /usr/local/bin/
then
install node newly: https://nodejs.org/en/
then
Install react: npx create-react-app my-app follow: https://create-react-app.dev/
For Linux this worked for me
sudo npm uninstall -g create-react-app
npx create-react-app my-test-app
TLDR: Uninstall the global package using npm uninstall -g create-react-app and generate new react apps using npx create-react-app app.
Issue
You're using an older version of create-react-app that you have installed globally using npm. The create-react-app command invokes this global package.
You could've confirmed that you were using an outdated version by running npm outdated -g create-react-app or comparing create-react-app --version with npm view create-react-app.
The fact that the version of react-scripts was up to date, has nothing to do with the version of the package that is bootstrapping the app (create-react-app), which grabs the latest versions of the packages that it uses (react-scripts in this case).
Solution
If you want to continue using the create-react-app command, you'll need to update the global package using npm update -g create-react-app. Note that you'll want to do this periodically to keep it up to date. You'll notice that create-react-app does not recommend this (noted in the logs from your install).
A better approach would be to delete the global install entirely (npm uninstall -g create-react-app) and instead use npx so that it grabs the latest version of the package every time (more detail on npx below).
You should confirm that it was uninstalled globally by trying to use create-react-app to make sure the command is "not found".
Issues with uninstalling?
You can debug where it was installed using which create-react-app. If you're having issues uninstalling it, you may have multiple versions of node/npm on your machine (from multiple installs, or because you use a node version manager such as nvm). This is a separate issue I won't address here, but there's some info in this answer.
A quick nuclear approach would be to forcefully remove it (rm -rf) at the path that which create-react-app returns.
Supplement
Global npm packages and the npx command
$ NPM_PACKAGE_NAME will always use the globally installed version of the package, regardless of which directory you're in.
$ npx NPM_PACKAGE_NAME will use the first version of the package that it finds when searching up from the current directory to the root:
If you have the package in your current directory, it will use that.
Else if you have the package in a directory that is a parent of your current directory, it will use the first one it finds.
Else if you have the package installed globally, it will use that.
Else if you don't have the package at all, it will temporarily install it, use it, and then discard it. - this is the best way to ensure the package is up to date.
More info about npx can be found in this answer.
Using npx with create-react-app
create-react-app has some special commands/aliases to create a react app (instead of npx) that are specific to that package (yarn create react-app, npm init react-app), but npx create-react-app will work the same as it does with other packages.
yarn vs npm global installs
Yarn stores global installs in a different folder than npm, which is why yarn create react-app would work immediately without uninstalling the global npm package (as far as yarn is concerned, the package hasn't been installed).
This is just a temporary solution though, as you'll need to remember to always use yarn instead of npm when using Create React App.
This works for me!
1) npm uninstall -g create-react-app
2) npm install -g create-react-app
3) npx create-react-app app_name
If you have any previously installed create-react-app globally via npm install -g create-react-app, Better to uninstall it using npm uninstall -g create-react-app
This solved my problem
Steps:
1.Uninstall the create-react app
npm uninstall -g create-react-app
2.Now just use
npx create-react-app my-app
this will automatically create the template for u .
This problem is not solved like this, the problem is in the different instances of node, try removing globally create-react-app and then delete the node_modules and package-lock.json from your root user
This work's for me :
Let's, uninstall create-react-app globally by this command:
npm uninstall -g create-react-app
After that in your project directory:
npm install create-react-app#latest
At the last:
npx create-react-app my-app
For typescript :
npx create-react-app my-app --template typescript
First uninstall create-react-app
npm uninstall -g create-react-app
Then run yarn create react-app my-app or npx create-react-app my-app
then running yarn create react-app my-app or npx create-react-app my-app may still gives the error,
A template was not provided. This is likely because you're using an outdated version of create-react-app.Please note that global installs of create-react-app are no longer supported.
This may happens because of the cashes. So next run
npm cache clean --force
then run
npm cache verify
Now its all clear. Now run
yarn create react-app my-app or npx create-react-app my-app
Now you will get what you expected!
I fix this issue on Mac by uninstalling create-react-app from global npm lib, that's basically what said, just try to do, you need also do sudo:
sudo npm uninstall -g create-react-app
Then simply run:
npx create-react-app my-app-name
Now should be all good and get the folder structures as below:
Using the command npm uninstall -g create-react-app didn't work for me.
But this worked:
yarn global remove create-react-app
and then:
npx create-react-app my-app
Such a weird problem because this worked for me yesterday and I came across the same error this morning. Based on the release notes, a new feature was added to support templates so it looks like a few parts have changed in the command line (for example, the --typescript was deprecated in favor of using --template typescript)
I did manage to get it all working by doing the following:
Uninstall global create-react-app npm uninstall create-react-app -g.
Verify npm cache npm cache verify.
Close terminal. I use the mac terminal, if using an IDE maybe close and re-open.
Re-open terminal, browse to where you want your project and run create-react-app via npx using the new template command conventions. For getting it to work, I used the typescript my-app from the documentation site to ensure consistency: npx create-react-app my-app --template typescript
If it works, you should see multiple installs: one for react-scripts and one for the template. The error message should also no longer appear.
npm uninstall -g create-react-app could be an answer in some cases, but not in mine.
You should manually delete your create-react-app located at ~/.node/bin/ or /usr/bin/ (just type which create-react-app and remove it from locations you saw using rm -rf), next just run npm i -g create-react-app.
After that create-react-app will be working correctly.
This worked for me
1.First uninstall create-react-app globally by this command:
npm uninstall -g create-react-app
If there you still have the previous installation please delete the folder called my app completely.(Make sure no program is using that folder including your terminal or cmd promt)
2.then in your project directory:
npm install create-react-app#latest
3.finally:
npx create-react-app my-app
For any Windows users still having this issue, this is what fixed it for me:
Run where create-react-app to get the path (mine was in C:\Users\username\AppData\Local\Yarn\bin).
Navigate to that directory and delete both "create-react-app" and "create-react-app.cmd".
Navigate to the directory you want to start a project in.
Run npm install create-react-app,
npx create-react-app name-of-app,
cd name-of-app, yarn start.
Step #4 will vary based on your configuration, but that's just what got me up and running.
One of the easiest way to do it is by using
npx --ignore-existing create-react-app [project name]
This will remove the old cached version of create-react-app and then get the new version to create the project.
Note: Adding the name of the project is important as just ignoring the existing create-react-app version is stale and the changes in your machines global env is temporary and hence later just using npx create-react-app [project name] will not provide the desired result.
npx create-react-app#latest {project name}
this seems to be the way to make it work.
After using this command:
yarn global upgrade create-react-app
I then tried:
yarn create-react-app my-app but it didn't work for me.
This worked though:
npx create-react-app my-app

Resources