npx create-react-app running with old version - reactjs

The latest version create-react-app is 4.0.3 but when I run npx create-react-app my-app it uses version 1.5.2 and also doesn't run with templates. I don't have any global installation of it and have tried uninstalling it using npm uninstall -g create-react-app.
My npm version is 7.21.1 and node version is 16.9.1
How can I make it work? Please help.
EDIT: There are 58 vulnerabilities while creating the app and this comes at the end -
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.
The folder also doesn't have the src folder just the node_modules folder and package.json file.
While running npm audit fix I get this -
tar <=4.4.17
Severity: high
Arbitrary File Creation/Overwrite on Windows via insufficient relative path sanitization - https://github.com/advisories/GHSA-5955-9wpr-37jh
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning using symbolic links - https://github.com/advisories/GHSA-9r2w-394v-53qc
Arbitrary File Creation/Overwrite due to insufficient absolute path sanitization - https://github.com/advisories/GHSA-3jfq-g458-7qm9
Arbitrary File Creation/Overwrite via insufficient symlink protection due to directory cache poisoning - https://github.com/advisories/GHSA-r628-mhmh-qjhw
fix available via `npm audit fix`
node_modules/tar
tar-pack *
Depends on vulnerable versions of tar
node_modules/tar-pack
create-react-app >=1.3.0-alpha.58689133
Depends on vulnerable versions of tar-pack
node_modules/create-react-app
3 high severity vulnerabilities

Short version:
npx clear-npx-cache
Temporary solution:
npx create-react-app#latest my-app
Now for the explanation. I think npx is running an old version of create-react-app on your computer. The first time you do npx create-react-app, the package is installed in the cache. npx does not check for newer versions if the package is cached. You can sidestep this issue by adding #latest. This forces npx to fetch the package even if it is cached.
A better solution is to clear the cache. There are other guides about how to find and remove the cache folder on windows and macos. The package clear-npx-cache does this.

Related

Can't use npx create-react-app "no longer support global installation of Create React App"

I can't create a new application using the create-react-app.
The command I am using is npx create-react-app appname --template typescript.
The error I get is:
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
I removed the global package with npm uninstall -g create-react-app. I then checked the packaged is not installed globally by
Running npm list -g
Checking the folder C:\Users\my-user\AppData\roaming\npm
But create-react-app keeps saying I have globally installed "create-react-app 4.0.3".
After all I did clean cache with npm cache clean --force and reboot computer but with the same result.
I am runnig on windows 10, npm 7.18.1 and node 16.4.0
What am I missing?
Thanks in advance
This caught me too. You need to run
npx clear-npx-cache
In my instance, I had an older version of create-react-app installed globally with yarn, and simply removing it fixed the issue.
yarn global remove create-react-app
Or, for NPM
npm uninstall -g create-react-app
I was then able to run npx create-react-app my-app without issue.

Getting this error while creating a new react app. Also tried the uninstall command but it doesnt work

While creating a new react app using npx create-react-app my-app i am getting this error saying "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." How can i solve this. Even tried using the uninstall command
create-react-app error
If you've previously installed create-react-app globally via npm install -g create-react-app, it's recommended 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.
You’ll need to have Node 14.0.0 or a later version on your local development machine (but it’s not required on the server). Its recommend to use the latest LTS version. You can use nvm (macOS/Linux) or nvm-windows to switch Node versions between different projects.
Moreover Here is the Documentation
You must first update the node version
and run
npx create-react-app app-name

A template was not provided. This is likely because you're using an outdated version of create-react-app (NPM issue)

I know this is an old issue but it showed up after upgrading my npm,
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 to fix it with:
npm uninstall -g create-react-app
yarn global uninstall create-react-app
npx create-react-app [name of folder]
It did not work
The next step, clean node cache
same issue
the last step I removed npm and node from my system and install it again
same issue.
There are some clues here but it does not work for me
source: Template not provided using create-react-app
I just want to repair this, not use flags command options.
Any recommendations are welcome anyway.
I removed all node and npm folders from
/usr/local/bin/node
/usr/local/bin/npm
even a ".npm" and ".node" hidden files that were in my user home folder, and I realize my IDE WebStorm had one also, so I removed my IDE as well, I rebooted the machine just in case as windows computer, and install Node and npm again "stable version" and then the IDE, it works at the moment.
source: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

Why can't I use the npx create-react-app command?

My version of npm and npx is 6.14.4 and my operating system is Windows 10. Before I could use this command.
Command line error message
try this feel free to help
npm cache clean --force
npm install -g create-react-app
npx create-react-app "Name-Folder-App Must Be LowerCase"
Or if you work with yarn
yarn create react-app my-app
if you have any problem with your project of npm make that
npm i -f
as stated by the create react app documentation:
Creating an App
You’ll need to have Node 8.16.0 or Node 10.16.0 or later version on
your local development machine (but it’s not required on the server).
You can use nvm (macOS/Linux) or nvm-windows to switch Node versions
between different projects.
Here is the link for de official documentation.
So you need to update your current nodejs version.

Create React App not working

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
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,
Please try this:
npm cache clean --force
I also got the same issue and tried to resolve for a long and finally resolved using this command,
npx create-react-app#latest my-app --use-npm
I had the same problem and had to do the following:
npm uninstall -g create-react-app
npm uninstall create-react-app
After this I was able to create the app with:
npx create-react-app project-app
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)
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.
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.
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
Edit 1: This may be due to slow internet speed, Please check the
internet and try again.
npx create-react-app .
( the .) means create project on this folder so you should manually create if you do that
For the windows machine following command worked for me
yarn create react-app my-app
cd my-app
yarn set version berry
yarn
yarn start
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.
on Ubuntu 18.04
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
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
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
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.
After no luck with updating my npm version and doing npm cache clean --force I ended up just doing a fresh install of node which fixed the issue for me.
HAD the same problem. Running Node with cra. installed cra -g for starters.
npm install -g create-react-app
then downgraded react-scripts to version 2.1.8
npm install react-scripts#2.1.8
created a .env file in root directory and added this to it.
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
SKIP_PREFLIGHT_CHECK=true
Then you do the typical delete node_modules folder and the package-lock.json file.(NOT PACKAGE.JSON!!!)
then:
npm install
npm start
This worked for me. Sorry I'm not more informative on why this worked for me. I'm still trying to understand why it didn't work in the first place.
I just did it now after messing around with it all yesterday.
Installed react globally like people have said.
then I used 'git bash here' to open terminal in the directory i want
oddly, it worked when I removed npm. I know it's weird, I've never had to do that and it makes no sense but its working so:
create-react-app my-app-name
I'm on windows 10 by the way.
If there is anyone having this issue that you can not find your project when you
yarn create-react-app (name of project)
npx create-react-app (name of project)
then just be sure that you are in the right directory.
use this command in your terminal
cd ..
now search the project name by
cd (project name)
you should find your directory here.
Please do this, I hope it will fix all of your problems
1- npm i -g create-react-app
2- create-react-app my-app
Find the folder and where a folder named npm is present and add it into environment variables (path)
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 :-)

Resources