why src and public folders missing in react creat app? - node.js

I am trying to create create app using npx create-react-app my-app
I have npm 6.13
and node : 12.14.1
I tired to follow the soultion in create-react-app doesn't generate public and src folders thus cannot get started
but it is not working ?
Any chance ?

You might have already installed create-react-app globally. but npx always uses the latest version of create-react-app. please check the create-react-app version by
create-react-app -v
and ensure its latest by checking Changelog.md. if not try uninstalling the global package by
sudo npm uninstall -g create-react-app
make sure you have uninstalled globally and then try running
npx create-react-app <project_name>

initially tried using but not worked: npm rm -g create-react-app, npm install -g create-react-app, npx create-react-app <your-app-name>.
below command works : npx --ignore-existing create-react-app <Your-AppName>

Related

I get an error installing create react app

I can't install react app normaly.The src and public folder is missing. I'm using node v18.13.0 and **npm v9.4.0 **
I did this command npx create-react-app my-site.And I expecting all dependencies to be installed but I got an error message
Installation
To start a new Create React App project with TypeScript, you can run:
npx create-react-app my-app --template typescript
or
yarn create react-app my-app --template typescript
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.
Global installs of create-react-app are no longer supported.
Troubleshooting
If your project is not created with TypeScript enabled, npx may be using a cached version of create-react-app. Remove previously installed versions with npm uninstall -g create-react-app or yarn global remove create-react-app (see #6119).
If you are currently using create-react-app-typescript, see this blog post for instructions on how to migrate to Create React App.
Constant enums and namespaces are not supported, you can learn about the constraints of using Babel with TypeScript here.
See here for full details: https://create-react-app.dev/docs/adding-typescript/
When the system has a globally installed CRA (create-react-app) and we try to create a new app with npx it fails due to the conflict. In order to fix this, we need to remove the global installation and then use npx to install a new app.
We can uninstall with:
sudo npm uninstall -g create-react-app
and then clear the npx cache
npx clear-npx-cache
There is an error with the command to create react app, the following is the correct one:
npx create-react-app my-app --template typescript

React Js, Template Not Provided On npx create-react-app <app name>

I'm starting a new react app using the
npx create-react-app <app name>
and am recieving an error of a template was not provided do the following ->
npx uninstall -g create-react-app
Well, I have done it and it hasn't helped. I've tried updating the current nodejs and npm versions, I've done a fresh install of nodejs, and I've cleared the npm and npx caches. I've also tried using specific create-react-app versions such as
npx create-react-app#latest(or some other version)
Nothing works, no template is ever provided, and I'm a little lost. Does anyone know another potential workaround? I'm open to manually downloading a folder containing the npx create-react-app post-completion contents if such a thing exists.
The React docs point out that you may have create-react-app installed via Yarn instead of NPM, and can try this also:
yarn global remove create-react-app
This SO answer suggests that if the npm uninstall -g create-react-app doesn't work, you can manually look to see if and where create-react-app may be installed.
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.
Are you on Windows or Mac/Linux? The which command works on Mac/Linux, but not on Windows. I don't know the best way to do this on Windows, but this thread has some suggestions for PowerShell.
My understanding of the npx command is that it psuedo-installs the package (in this case, create-react-app) to ensure that we're using the latest available. It's convenient and recommended, but it isn't required. If you continue having issues, I would personally try fully installing create-react-app to see if I can scaffold a new project that way:
npm install -g create-react-app
create-react-app my-app

npm global uninstallition of old version of create-react-app not working

Today i was trying to create a new react application after a long break i took.
when i tried npx create-react-app, it gave me the following error:
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
When I try to uninstall the old version of create-react-app using npm uninstall -g create-react-app
it shows the output:
up to date, audited 1 package in 432ms
found 0 vulnerabilities
Then when i try to run npx create-react-app again, it shows the same error. can you please help me.
Try npx clear-npx-cache before running npx create-react-app again.

when i try to create react app ,i get " template was not provided ,This is likely because you're using an outdated version of create-react-app " Error

when i try to install react app with following code
npx create-react-app app1
i get following problem
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.
You can fix this by running npm uninstall -g create-react-app or yarn global remove create-react-app before using create-react-app again.
i tried npm uninstall -g create-react-app and still it gives the same error , i don't know where the issue lies.
my system info
os : Windows 10 64 bit
nodeJs : v14.15.0
npm : v6.14.8
is this a problem with the node version..? How to solve the issues
Try to remove create-react-app from node_modules from user root
and npx create-react-app myapp should work.
or
npx --ignore-existing create-react-app
I searched for create-react-app on my whole mac through finder and deleted that folder. Then it worked
Make sure that there is no file named create-react-app anywhere:
You can use: where create-react-app in windows to locate it, if that doesn't work, search for it in the file explorer and delete it, that worked for me
Implement the following steps:
Write this code into your editor:
npm install --global yarn
And then upgrade:
yarn global upgrade
Create your app. You can choose your app name:
yarn create react-app your-app-name
Go to your app directory:
cd your-app-name
Delete the folder with the title create-react-app from your machine then
npx create-react-app my-app
this must fix your problem...

Create-React-App does not create starter template

I'm trying to create a new project with the typescript template as per these instructions.
npx create-react-app app-ui --template typescript
Although it installs all the node modules it does not create the starter project nor does it use the provided template. I get this message:
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.
I'm attempting to follow the instructions and delete the global install of the cli but that also doesn't work:
npm uninstall -g create-react-app
up to date in 0.037s
No matter what I do I cannot uninstall the cli. What is going on?
Edit:
I was able to get it partially working on PC.
npm remove create-react-app
then
npx create-react-app my-app [--template typescript]
I tried with brackets and although the template project is there it isn't in typescript. There's something very wrong with the cli right now.
Edit:
This post solved the issue of not being able to uninstall the cli. Hope this helps someone and please upvote the OP.
For OP:
Your brackets are out of place.
For your case, the documentation docs says to use:
npx create-react-app my-app --template [template-name]
or
npx create-react-app my-app --template typescript
For everyone else:
Uninstall (I'm on Linux/Ubuntu)
sudo npm uninstall -g create-react-app
Then run:
npx create-react-app my-app
Note: Be sure that all the folders/files were removed on the uninstall. If you're having trouble accessing a the react folders in your linux setup as I was (due to permissions), gain access and remove by:
sudo chown -R $USER /usr/bin/create-react-app
(...and then do the npx command.)
I resolved this issue by sudo npm uninstall -g create-react-app
but this did not remove create-react-app, so I had to check in which directory it is located. In the terminal, if you type:
which create-react-app
it will give you some directory like /usr/local/bin/create-react-app
Now do:
rm -rf /usr/local/bin/create-react-app
This will remove create-react-app manually. Now you can start creating react app using
npx create-react-app my-app
I was having the same problem. This works for me (Linux)
Step 01.
sudo npm remove create-react-app
Step 02.
sudo npm uninstall -g create-react-app
Step 03.
npx create-react-app my-app --template typescript
I hope this helps.
Create React Startup template
1.npx create-react-app your_app_name
2.cd your_app_name
3.npm start
Even if you ran npm uninstall -g create-react-app create-react-app may still be installed. You can check by running which create-react-app. If a path is returned create-react-app is still installed. You can delete the module with rm -r ${returned path}. After that running npx create-react-app app-ui --template typescript should work without errors or warnings.
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.
When i executed
create-react-app hello
only generated below folder structure, with notification
"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."
node_modules
package.json
yarn.lock
Followed below steps to resolved
// Uninstalling create-react-app package
npm uninstall -g create-react-app
After that i am ready to create new react app through "npx"
For ES6 flavour (Default it will take ES6 language)
npx create-react-app hello-world
For Typescript flavour
npx create-react-app hello-world --template typescript
Following are the folder structure after running above cmd
README.md
node_modules
package.json
public
src
yarn.lock
yarn start //Works fine
node: v10.16.0
npm: 6.10.2
My solution ended up being a little different than yours so I will add it here just in case someone has a similar issue. Apparently I installed create-react-app globally with yarn which I could see when I ran which create-react-app which resulted in a path like .../.config/yarn/global/node_modules/.bin/create-react-app. Running yarn global remove create-react-app removed this package and then I was able to run npx create-react-app app --template typescript successfully.
Install create-react-app
In the beginning, we have to install create-react-app tool. It’s a tool provided by React.js creators, which allows installing ready to use React.js application, with all needed dependencies. To install the tool, we have to use the following command in the command line:
npm install -g create-react-app
Create the application
Now, it’s super easy to create our first application using the create-react-app tool. We can do it with a single command in our command line. First, navigate to the folder where you want to have your application through the command line, and then run the following command, where reactapp is the name of our application:
npx create-react-app reactapp
You can feel free to set a different name for your application. If the process finished successful, you should have your folder with the app ready! Let’s start the application now!
Start the application
Let’s start our reactapp with the following commands:
cd reactapp
npm start
The first command is used to enter the folder of our application, and the second one starts our app. By default, the application is open at localhost:3000, but we can change the port in the settings.
Link: https://dev.to/duomly/how-to-create-the-react-app-in-5-minutes-1bmb
Hpe this helps!
For Windows users, follow two steps
npm uninstall -g create-react-app
Then
npx create-react-app jamming
keep updating your node and npm, latest stable version
Uninstall create-react-app using command:
sudo npm uninstall -g create-react-app
Since npm is not supporting global use of npm modules.
install create-react-app boiler-plate as usual using command:
npx create-react-app my-app
it works!!
I faced the same problem using Command Prompt in Windows, but then I tried the following steps on Powershell it worked. If still it is not working then Run Powershell as Administrator.
npx create-react-app my-app
cd my-app
npm start
I was having the same problem. I tried this
npm install -g create-react-app
Then do the create-react-app app-name It worked out for me.

Resources