问题
Help! I have no idea what is going on here, create react app is not working I have also tried reinstalling and yet to no avail, please help!
Npm version: 5.4.2 Node version: 8.70
Tried the npm install --save --save-exact --loglevel error react react-dom react-scripts
回答1:
Please try this:
npm cache clean --force
回答2:
In my case, "create-react-app" was not installed. to install run this command
npm install -g create-react-app
Once installation successful, try running
npx create-react-app hello-world
If this works for you. Great else comment what worked for you,
回答3:
It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production.
You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. To create a project, run:
npx create-react-app my-app
cd my-app
npm start
Note: npx on the first line is not a typo — it’s a package runner tool that comes with npm 5.2+.
Create react app provides more information regarding this.
It may be the problem of cache also, so can also try:
npm cache clean --force
回答4:
Make sure you are not running any antivirus, stop/pause all antivirus or protection software.
You can also try
use create-react-app projectname --save
or create-react-app projectname --save-exact and start again
OR
as the error suggests, you should use a newer version of node. You are using 8.9.4, you should probably use 8.12.0 LTS.
回答5:
I had the same problem, and I solved it by:
1. update the npm version (npm install npm@latest -g)
2. clear the cache (npm cache clean --force)
3. create the react project (npx create-react-app todo)
(create-react-app was already installed)
回答6:
The problem on my machine was caused by yarn. I am windows 10 and after uninstalling yarn using npm uninstall -g yarn, my script run correctly. So
- Open terminal and type: npm uninstall -g yarn
- Once done, close terminal and open new one
- type create-react-app (app name) and this should create your app :)
Please note that the above steps assume that you already have node and react-cli installed on your machine.
回答7:
on Ubuntu 18.04
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
回答8:
What I did, is going to
C:\Users\mycomputerName\AppData\Roaming\npm\
I changed the name of this file
create-react-app.ps1
to
create-react-appOld.ps1
or you can delete it, then it worked fine
回答9:
Tried all the above methods but no luck:(
Step1 : Reinstalled Node js
Step2 : Check whether environment variables has been created. if not create one for nodejs,npm and composer
Step3: Also add "C:\Windows\System32" to the global PATH environment variable.
Step4: Then use "npx create-react-app my-app" to create react project
Step5: Run the commmand : cd my-app and npm start
Step6: It will work
回答10:
If npm cache clean --force
doesnt work please run the following
npm init react-app project-name
Replace 'project-name' with the name of the folder you'd want. Goodluck
回答11:
I had similar issue while tried creating new react app with create-react-app
, but related to some random JSON reading issues while installations like.. >= 5.0 || 4.0 ..
But the fix below solves multiple and similar issues.
First of all, make sure you have required or latest version of node installed.
npm install npm@latest -g
Before using create-react-app
make sure you clean npm cache using npm cache clean --force
Now, is should be fine to create new react app with npx create-react-app tl-app
or npx create-react-app .
if you want to create current directory as project root.
回答12:
I finally got it to work. An anti-virus in my system was causing it not to work property. I unistalled it and it's working as expected.
回答13:
I also experienced the same problem and SOLVED IT. This is what I did.
- Restart your machine(computer)
- Deactivate your anti-virus. I chose the "permanently" option
- Open the terminal and run the "create-react-app" command again, It will definitely do the trick.
- Activate your anti-virus
- And get working :-)
来源:https://stackoverflow.com/questions/47843056/create-react-app-not-working