npx not creating public and src folders in react - reactjs

when executed the command to create the env for react
npx create-react-app myfirstapp,
command was successfull but there were few warnings.
Src and public folders not created.
OS Windows 10 home edition.

Had similar issues, I solved it by executing:
npm install -g create-react-app
create-react-app >>app-name<<

Related

Not able to find public , src, .gitignore on my react app on mac

I have created the react app by using the "npx create-react-app filename ", on mac terminal after this when i opened the file using vs code it it didn't had the files i.e, .gitignore,public and src what could be the reason , I have followed all the steps very carefully installing the latest version of node etc.
if you have installed create-react-app globally . you should uninstall it using npm uninstall -g create-react-app . then run npx create-react-app my-app

Src folder is not created while create-react-app

While creating the react-app by = " npm create-react-app "
src and public folder are not created
I tried:
npx craete-raect-app
npm rm -g create-react-app,
npm install -g create-react-app,
npx create-react-app .
npx --ignore-existing create-react-app Your-AppName
i tried these all but failed to create the src folder.
Try to run this command npx craete-raect-app app-name
First of all check whether you have node installed on your machine:
Run this command:
node -v
It will show your node version if installed.
Next step you are not even creating an app. Give it a name app-name
npx create-react-app app-name
This will create your app with src and public folder inside it.
Go to your app by:
cd app-name
npm start

How to make create-react-app use npm instead of yarn?

I kind of rushed into creating a React app based on a tutorial that used yarn. Now I'm going to re-create the app from scratch because I'm not satisfied with the reactstrap library, and I'd like to switch to react-bootstrap.
I've re-installed node. However, when I run create-react-app, it says to use "yarn" instead of "npm" as follows:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd react-test
yarn start
I'd like to use npm because it seems like it's more widely used and there are more examples based on it. Am I stuck with yarn, or can I go ahead and use npm?
You can either
1) Remove yarn.lock, and running npm i,
or
2) Run create-react-app app --use-npm
1 ⇢ If you have installed create-react-app then use:
create-react-app --use-npm
2 ⇢ If you are using npx command then use:
npx create-react-app --use-npm
3 ⇢ For existing yarn app, remove the yarn.lock file and run:
npm i
or
npm install
Install create-react-app npm i -g create-react-app --use-npm
Go to desired path using cd command
Add --use-npm create-react-app my-app-name --use-npm
This command will create a folder with the name that you mentioned inside your current path . This folder consists all necessary configuration files needed for a starter code for react application
# Run this to create-react-app using npm
npx create-react-app my-app
# Or run this to create-react-app using yarn
yarn create react-app my-app
I dont know if this helps. But I was having the same problem and did this
npx expo-cli init --npm
and it installed with npm
hope this helps you or someone in the future
For latest versions, the flag is changed to --npm
So if you want to use npm then use it like
npx react-native init YourProject --npm

create-react-app bash: /usr/local/bin/create-react-app: No such file or directory

I had an origonal problem that I tried to fix and got another problem
1. ORIGONAL PROBLEM
I just tried to install a new react app using create-react-app and got this error first
Please note that global installs of create-react-app are no longer supported.
The node modules were installed but none of the other files or directories that normally install.
2. What I did to fix Origonal problem
on the react app website it https://create-react-app.dev/docs/getting-started/ it was suggested that I do the following (which I did)
"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."
I tried to run the command npm uninstall -g create-react-app but could not do it as my mac prevented it so ran sudo npm uninstall -g create-react-app
3. New PROBLEM
When I now run create-react-app I get the message
bash: /usr/local/bin/create-react-app: No such file or directory
TDI-MacBook-Air:Active bob$
What do I need to do to get create react App back. I am worried about messing up my installation more so am hesitant to go at it without some advice
Just simply run npx create-react-app app_name to create your app.
npx will fetch the latest version of create-react-app and setup your app.
This solved my error Just simply run npx create-react-app app_name to create your app. npx will fetch the latest version of create-react-app and setup your app.

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

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 :)

Resources