Error with terminal when trying to create-react-app - reactjs

I'm trying to create a new react app, but I can't seem to do it. I have searched everywhere and done everything I could that can be done nothing is working. I have deleted node, npm, and npx two times and downloaded again, and then restarting my computer like 100 times but nothing works:
Need to install the following packages:
create-react-app
Ok to proceed? (y)
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
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
my#mycomp-MacBook-Pro ~ % npm uninstall -g create-react-app
up to date, audited 1 package in 176ms
found 0 vulnerabilities
my#mycomp-MacBook-Pro ~ % npx create-react-app my-app
Need to install the following packages:
create-react-app
Ok to proceed? (y)
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
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
my#mycomp-MacBook-Pro ~ %
And after that if I try to npm uninstall -g create-react-app or anything else it alwayse send this error:
my#mycomp-MacBook-Pro ~ % npm uninstall npm uninstall -g create-react-app
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/npm',
npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mycomp/.npm/_logs/2021-12-15T12_37_53_679Z-debug.log
my#mycomp-MacBook-Pro ~ %
How can I fix this?

The problem seems to be that of an inappropriate installation. The go-to way to fix this would be to ensure a proper uninstall of node and npm. Please follow the steps mentioned here. Once properly uninstalled, head over to install node and proceed with the re-installation.

First, remove the package. If you have installed create-react package using npm then use
- npm uninstall -g create-react-app
or if yarn
- yarn global remove create-react-app
Then you can create a project:
npx create-react-app my-app

Related

Trying to install Expo-cli, But experiencing Error Codes like NPM Install Errors Like EACCES, AND ENOEMPTY

I am new to react native and I am having an issue installing expo-cli, and I get two different errors depending on how I try to install expo-cli. If I do npm install --global expo-cli, it gives the EACCES error.
This is what the problem looks like:
npm install --global expo-cli
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /Users/mac1/.npm-global/lib/node\_modules/expo-cli
npm ERR! dest /Users/mac1/.npm-global/lib/node\_modules/.expo-cli-sUcgOQ3i
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 501:20 "/Users/mac1/.npm"npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac1/.npm/\_logs/2021-12-28T04\_20\_03\_084Z-debug.log
When I input sudo npm install expo-cli -g --unsafe-perm, it gives an ENOEMPTYerror like this
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/mac1/.npm-global/lib/node_modules/expo-cli
npm ERR! dest /Users/mac1/.npm-global/lib/node_modules/.expo-cli-sUcgOQ3i
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/mac1/.npm-global/lib/node_modules/expo-cli' -> '/Users/mac1/.npm-global/lib/node_modules/.expo-cli-sUcgOQ3i'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac1/.npm/_logs/2021-12-29T00_39_39_814Z-debug.log
It is important to add that I have tried to other methods that might solve this problem like, yarn add global expo-cli , sudo chown, npm cache clean --force, . But nothing has worked, I'm not sure if the methods don't work, or if I'm doing the procedure wrong.
Thank You for Your Time!
Option 1: I would recommend you install node js by using the nvm(node version manager). That way you can have different versions of node js installed on your system and you can easily switch versions. Then try using an earlier node version like 14 to install expo-cli
Option 2: Debug - Go through the log file, you are going to see where the error is coming from1

I'm having a hard time running a react command

I just updated my npm and got rid of some useless packages, but for some reason, I still am running into some weirdness when trying to run this command
kalebamarante$ npm init create-react-app kalebcryptoexchange-app
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/create-create-react-app - Not found
npm ERR! 404
npm ERR! 404 'create-create-react-app#latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kalebamarante/.npm/_logs/2021-03-09T00_18_58_939Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ npx create-react-app kalebcryptoexchange-app
You are running `create-react-app` 4.0.1, which is behind the latest release (4.0.3).
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
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
npm ERR! code 1
npm ERR! path /Users/kalebamarante
npm ERR! command failed
npm ERR! command sh -c create-react-app kalebcryptoexchange-app
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kalebamarante/.npm/_logs/2021-03-09T00_20_01_995Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ sh -c create-react-app kalebcryptoexchange-app
kalebcryptoexchange-app: create-react-app: command not found
you should try npx instead of npm init.
npx create-react-app kalebcryptoexchange-app.
You should use npx instead of npm.
npx create-react-app your-app
Now why is that?
When you are using npm command it will get the node packages for you. i.e. You may have installed the package called 'create-react-app' globally using npm. Now to execute that package you have to use npx command.
Your error log shows this line,
npm ERR! 404 'create-create-react-app#latest' is not in the npm registry.
because you are trying to fetch a package instead of creating it using create-react-app.
In short, npm downloads the packages, npx execute a package.

could not create react project

I was trying to create a react project using the command
npx create-react-app chat-app
But I am getting this error.
Creating a new React app in /home/mikhil/react-tutorial/internshala-react-course/chat-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! npm ERR! Found: #babel/core#undefined
npm ERR! node_modules/#babel/core npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #babel/core#"^7.0.0-0" from #babel/preset-env#7.13.10
npm ERR! node_modules/#babel/preset-env
npm ERR! #babel/preset-env#"^7.12.1" from #svgr/webpack#5.5.0
npm ERR! node_modules/#svgr/webpack
npm ERR! #svgr/webpack#"5.5.0" from react-scripts#4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts#"*" from the root project
npm ERR! npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/mikhil/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mikhil/.npm/_logs/2021-03-18T11_58_50_255Z-debug.log
Aborting installation. npm install --save --save-exact --loglevel
error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting chat-app/ from /home/mikhil/react-tutorial/internshala-react-course
Done.
You can try to update npm with npm update and see if that fixes it, and if not you can try these steps.
If you've previously installed create-react-app globally via npm install -g create-react-app, it is 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.
You will also want to delete your remnant files and folders for chat-app
Once you are in the /home/mikhil/react-tutorial/internshala-react-course directory and you have removed the global installations you can try running these commands.
npx create-react-app my-app
cd my-app
npm start
Create React App - Getting Started
I was having the same issue with NPM version 7.20.0.
Simply install an older version of NPM.
In the terminal run: npm install npm#6.14.11 -g
There appears to be some particular versions of NPM that cause this issue. Try updating to the very latest version of NPM.
I was also trying to do the same the whole day, then at last I have to open the documentation, there it was mentioned that you can also create react app using
npm init create-react-app **app_name**
and it worked for me fine.
I was troubled very much by this dependency thing.

React-bootstrap not installing due to husky error

I am trying to install react-bootstrap.
Yesterday I managed to successfully install react-bootstrap but I then later uninstalled it. Today I tried to reinstall it in the same project but it gives me the bellow errors.
I then created a new react app as a test in order to try and install react-bootstrap, but it failed with the same errors.
It seems that there is an issue relating to husky, so I installed this package but that did not help either.
I am using macOS.
noahgwynn#Noah frontend % npm i react-bootstrap
npm ERR! code 127
npm ERR! path /Users/noahgwynn/Documents/code/udemy-mern/frontend/node_modules/#popperjs/core
npm ERR! command failed
npm ERR! command sh -c husky install .config/husky
npm ERR! sh: husky: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/noahgwynn/.npm/_logs/2021-02-20T19_52_28_911Z-debug.log
noahgwynn#Noah frontend % npm install --save react-bootstrap
npm ERR! code 127
npm ERR! path /Users/noahgwynn/Documents/code/udemy-mern/frontend/node_modules/#popperjs/core
npm ERR! command failed
npm ERR! command sh -c husky install .config/husky
npm ERR! sh: husky: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/noahgwynn/.npm/_logs/2021-02-20T19_55_15_427Z-debug.log
noahgwynn#Noah frontend %
Your help is appreciated.
EDIT: Problem fixed!
Just tried "npm i react-bootstrap" again and this time it worked. It's a couple of hours later, not sure what changed but I'm happy it did.

create-react-app Failing to create a new React app in windows 10

I have Create-react-app version 1.4.3 installed. When I try to create a new App , I get the following messages in the command prompt. Please help me find and fix the issue.
C:\Users\GSI-KOL\Desktop\server>create-react-app client
Creating a new React app in C:\Users\GSI-KOL\Desktop\server\client.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
uglifyjs-webpack-plugin#0.4.6 postinstall C:\Users\GSI-KOL\Desktop\server\client\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js
npm ERR! path C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR! { Error: EPERM: operation not permitted, lstat 'C:\Users\GSI-KOL\Desktop\server\client\node_modules\fsevents\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path: 'C:\\Users\\GSI-KOL\\Desktop\\server\\client\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\GSI-KOL\AppData\Roaming\npm-cache\_logs\2017-11-08T13_08_03_705Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting client / from C:\Users\GSI-KOL\Desktop\server
Done.
C:\Users\GSI-KOL\Desktop\server>
I was faced this same problem . It is due to the issue with npm .
please run the following command in command Line
npm cache clean --force
then run
create-react-app <project Name>
If your problem still exist then switch from npm to yarn
run the following commands, it solved my problem
npm install -g yarn
yarn global add create-react-app
create-react-app <projectname>
It looks like you need admin privileges to write some of the generated files. Can you create a terminal instance with administrator rights then reissue the command?
You probably had "create-react-app" running before, which was the problem in my case anyway. The way I solved this was using
npm cache clean --force and ran create-react-app my-app again.
I suspect NPM has an issue. However, this was how I was able to resolve it
Follow this steps:
npm install -g yarn
yarn global add create-react-app
Create-react-app <projectname>
npm cache clean --force
Then try
npm create-react-app navigate
I also faced same issue and I rectified it using the comment
given below:
npm cache clean --force
After this comment try:
npx create-react-app project_name
Just run this one command to resolve issue:
sudo chown -R 1001:1001 "/home/<user_name>/.npm"
This is due to the network issues try to download all dependency one by one or try to clean cache "npm cache clean --force" after this try to create an app
npx create-react-app <app__name>. But your internet connection should be stable.
I tried the npm cache clean --force and the yarn route but, neither worked. What worked for me was running Powershell as Administrator then entering:
set-executionpolicy remotesigned
try this
npm install -g yarn
yarn global add create-react-app
create-react-app my-app
I had the same problem and this was solved to me with these steps:
Be sure that you have the lastest version of Node.js installed. (https://nodejs.org/)
npm install -g create-react-app
create-react-app client-app --use-npm or npx create-react-app client-app --use-npm
i hope it helped..
this should work
npm cache clean --force
I was also facing the same issue, here is how I fixed it :
1. I first cleaned my cache using the --force keyword
2. I reinstalled create-react-app globally
3. I recreated my app.
Illustration:
clean your cache
npm cache clean --force
Reinstall create-react-app globally
npm i -g create-react-app
Recreate your app
create-react-app .
This is what I did
npm install -g yarn
then this
npx create-react-app my-project
For me, i wasn't connected to the internet when i tried to run 'create-react-app', so i connected and tried it, it worked, i'm guessing it needed to install some packages from the internet.
Creating a new React app in C:\Users\CM\Downloads\react\github-profile.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! path C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b1
0893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6
5545008a3cad93d00f806'
npm ERR! { [Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1f
a335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec6554500
8a3cad93d00f806']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1
fa335b10893d67f7339e4
af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, lstat
'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996
b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015
eec65545008a3cad93d00f806'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'lstat',
npm ERR! path:
npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-
v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335
b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93
d00f806',
npm ERR! parent: 'postcss-image-set-function' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a
text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-
check thenpm ERR! permissions of the file and its containing directories, or
try running
npm ERR! the command again as root/Administrator (though this is not
recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\CM\AppData\Roaming\npm-cache_logs\2019-03-22T10_
27_19_722Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-
scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting github-profile/ from C:\Users\CM\Downloads\reactDone.``
i was facing similar error but i tried to run create-react-app command many times and finally it was created , this was the problem with my internet connection. check your inernet connection
I also encountered with the same problem, According to the error, you have a problem with your npm.
Try this command
sudo chown -R 1000:1000 "<location of npm>/.npm"
just take an example of my command
sudo chown -R 1000:1000 "/home/vidit/.npm"
All you need is npm cache clean --force
Works 100%
In my case, it happened when I aborted a wrong command I initiated.
Then I ran npm cache clean --force and the cache was cleaned; after that, I ran my npx create-react-app and it worked perfectly as it should.
Quick tip: Uninstall create-react-app from your machine like so, npm un -g create-react-app and run npx create-react-app instead of npm create-react-app any time you want to create a new react app.
Reason: npx will always use the latest version of create-react-app to create a new react app for your project, and npx uninstalls/removes the create-react-app package from your machine when it's done.
Don't worry, it takes about 20 seconds to install the create-react-app package, so...
Do not forget to npm cache clean --force when npx create-react-app goes bananas (i.e. refuses to work).
I faced the same problem, and I did these to solve the problem;
npm clean cache --force..
this didn't work... I returned a warning npm WARN using --forcing recommended protection disable.
I ignored that and did and reinstalled create-react-app globally by running;
npm i -g create-react-app
I created my app(project name) by running;
create-react-app my-app-name
I believe this should work for you..
I face the same issue.
I Try this But it does not work for me
npm cache clean --force
So uninstall Node
and install the latest version. It's worked for me
Hope it works for you :)
I resolved the same issue by changing the timeout time to greater than 30000
npx create-react-app appname -timeout=90000
In my case, none of the above mentioned worked for me. What fixed the problem was updating the npm:
npm install npm#latest -g
I did this because in the new LTS version (16.15.1) of NodeJS, npm was updated from 8.5.5 to 8.13.2.
just instead using the git-bash as a terminal use Windows powershell as a terminal it will work
in your system go to this location
C:\Users\user\AppData\Roaming
and inside that you will find a folder named "npm" delete that folder
and try npx create-react-app command again. conform it will work
My problem was similar and unlike others cleaning cache by using (npm cache clean --force) wasn't working out for me
this helped me instead
npx create-react-app my-app --use-npm
hope this does the trick for anyone who isn't getting result from cleaning cache
This worked for me
run npm install -g create-react-app (it will install create-react-app globally)
then create your app by running npx create-react-app [project-name]
This was my error:
3695 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\****\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
3696 verbose node v6.10.3
3697 verbose npm v6.4.1
3698 error code Z_BUF_ERROR
3699 error errno -5
3700 error zlib: unexpected end of file
This solved the issue:
npm cache clean --force and ran create-react-app my-app

Resources