when I type npx-create-react-app my-app in terminal for creating my react project but that would tell me npx command not found ?showing error npx command not found in it
The fastest way to solve this issue:
npx clear-npx-cache
If the error is not resolved, you can force the command to use the latest version of 'create-react-app':
npx create-react-app#latest <app-name>
I think you might be facing issues due to following reason
Your username has space in between Raheel Ahmed, if possible you can create new user in windows and have username without space.
Powershell some time through error related to permission, if you cmd or best is git bash
You would need to have LTS version of Node.js installed, I think you might be having that.
I would recommend trying 2nd option first, that is installing git bash and try running the command there.
If that also does not work then give 1st option a try.
why is this occurring? I've tried to set my path variable correctly but maybe I did it wrong and hope that's the reason zsh can't find the command "create-react-app" after installing it. I have very little experience in the terminal and am hoping someone can help me out.
On the command line you have to run npx create-react-app (for npm)
This is because when packages are installed globally, they are still just plain JavaScript. You need the npx command to run the installed package's code.
With lots of issues while installing react.js finally when I thought that issues were resolved and everything is in a good place. I found this as a heartache issue.
Error description Image for reference:
Whenever you see this error, it means that something went wrong when you installed the dependencies.
The proper method to fix this error and install all the dependencies again can be found in this answer.
A quick workaround can be to install this specific dependency again using the following npm command:
npm intall react-scripts start
This will help you solve this issue. I still recommend you to install all the dependencies again so that you won't run into such issues later on.
Please mark this answer as accepted if it solves your issue.
Please execute the below-mentioned command.
npx i -g create-react-app
It takes few minutes and displays a message similar to below
We suggest that you begin by typing:
cd your-app-name
yarn start
Happy hacking!
cd into the your-app-name folder and execute npm start
Additional Reference: https://reactjs.org/docs/create-a-new-react-app.html
**what is the difference between setting up react-native- cli with npm install -g react-native-cli and init versus using npx react-native init ?
I recently got a lot of eneont errors while developing react-native app. firstly i setup my system with npm install -g react-native and was working fine but later while installing dependencies they got eneont errors like could not find fsevent, nanoid, hammerjs etc.
And the official documentation includes setup to use npx. I really got confused with this sort of approach.
could you please light some knowledge on npm vs npx and installing with '-g' argument?
npx is a npm package runner (x probably stands for eXecute). The typical use is to download and run a package temporarily or for trials.
With npm you install the package on your machine. And global makes it available to all your projects not only the one where you currently work in.
As yesIamFaded pointed out, the npx command does indeed download the package for each time you run the code and from a networking standpoint it might beneficial. However, as per React-Native documentation (which you can find here) the cli has been deprecated and it may cause issues. To quote the doc:
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues.
So personally i would not go near it.
It's my first time trying to use it, but after executing:
create-react-app myproject
I get:
Creating a new React app in C:\project
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
[ ................] \ fetchMetadata: sill resolveWithNewModule js-tokens#4.0.0
And it just hangs there forever.
I'm using npm 5.6.0 and create-react-app 2.0.3 on Windows 8.
I had this problem, mine got stuck at
Creating a new React app in C:\project
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
[ ................] \ fetchMetadata: sill resolveWithNewModule react-is#4.0.0
The solution for me was to ensure npm is up to date by running:
npm install npm#latest -g
After this, create-react-app worked correctly.
If you get stuck while running create-react-app, just Ctrl + C to end the process in the terminal or CMD.
Then end task "node.exe" from task manager (if you use windows).
Then run in your terminal:
npm install npm#latest -g
npm install create-react-app -g
npx create-react-app (your-project-name)
cd (your-project-name)
npm start (inside your code editor, e.g. VSCode)
Note: beware of npm vs npx in the commands used above
What I just did is press ctrl + C. My intention is to abort the process, but turns out the process is continue. Still not know any further logical explanation of the 'solution' that I just did, though.
Re-install Node js 32 bit.
My problem got fixed and same issue was there. Solution is to uninstall Node js and reinstall 32 bit Node js.....Enjoy Thanks
I was having the same problem, what i did is to run the command in nodejs command prompt instead of command prompt. it worked for me
Since you have npm 5.6.0, let try using npx
Open cmd:
Locate to you C:\project
C:
cd C:\project
Run npx and start the sample project with npm:
npx create-react-app myproject
cd myproject
npm start
npx come out since npm 5.2, and just read the document from create-react-app here
Open a new terminal/CMD, type resmon and hit enter. Go to overview tab and search for
cmd.exe (for windows users), straight to that, search for suspended. Yes this is the culprit. Right click on that suspended, and click 'resume process' and hit enter.
Click continue if any pop-up occurs :).
That's it you are done. you will see that your installation will continue :).
Repeat the same process if CMD hangs.
adding nodejs path in User Variable worked for me.
Try this; it worked for me:
npm install -g create-react-app
then run your command.