I am trying setup react new setup but it is give me below error
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Error: Cannot find module '#csstools/normalize.css'
can anyone suggest me to move forward
thanks in advance
I'm able to solve the problem. The problem is that package-lock.json is pointing to the older packages.
To fix, uninstall an install the package again
Uninstall package
$ sudo npm remove csstools/normalize.css
After that, we have to install again
$ npm install csstools/normalize.css
(removing sudo from the npm install command)
rm -rf node_modules
npm cache clean --force
npm install
now try again to run your scripts, it should work
https://github.com/react-toolbox/react-toolbox-example/issues/28
I solve the same problem. The problem is that package-lock.json is pointing to the older packages. Not sure which package is but needs to be updated. The gist is that, you create a fresh reactapp, use your "package.json" to recreate "package-lock.json", and move it over back to your project. Do it AFTER you update the npm and clear the cache. Unfortunately, I didn't keep the exact sequence as I was trying to solve, following steps should be pretty close to what I did.
$ sudo npm cache clear --force
$ sudo npm install -g npm
$ cd <MYREACTAPPDIR>
$ npm install react#latest --save
$ cd ..
$ npx create-react-app tempapp
$ cp <MYREACTAPPDIR>/package.json tempapp/package.json
$ cd tempapp
$ npm install
$ cp package-lock.json ../<MYREACTAPPDIR>
$ cd ../<MYREACTAPPDIR>
$ rm -fr node_modules
$ npm install
$ npm run build
This worked for me (unfortunately a really annoying solution since it gets wiped whenever node_modules gets reinstalled), when recreating with npx create-react-app did not work.
Go to react-app/node_modules/#csstools
Change the name of the normalize.css folder into something else (ex. anormalize.css)
Take the files from the folder and paste them into the #csstools folder
Delete the anormalize.css folder
Source
fixed issue by updating npm to latest version.
sudo npm install npm#latest -g
If you're getting this error, chances are that you haven't used npx to create the react app. You must have used -
create-react-app project_name
Delete the project folder and reinstall it using -
npx create-react-app project_name
It should work this time. npx is a tool for node packages, which also installs some third party packages that running create-react-app alone might not install, hence throws the error.
Related
I am getting this create React app error again and again even after doing the uninstall part.
npm uninstall -g create-react-app
up to date, audited 1 package in 570ms
found 0 vulnerabilities
npx create-react-app test-app
Need to install the following packages: create-react-app Ok to
proceed? (y) 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/
C:\>npm --version
8.3.0
C:\>node --version
v16.13.0
How can I fix this?
Try running npx clear-npx-cache to clear your npx cache and then running the npx create-react-app your-app command.
Also have a look at this answer on clearing the cache.
Additionally, it might be worth trying to force the latest version with:
npx create-react-app#latest my-app --use-npm
I have resolved with the following steps:
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app myapp
Solution 1: Force to the latest version
Just try to run the create command with force to the latest version. Just like this:
npx create-react-app#latest_version my-app --use-npm
And the latest version is 5.0.0 so just try this command:
npx create-react-app#5.0.0 my-app
Now, your error must be solved.
Solution 2: Clear the cache
You just need to clear your cache and then you can create a new React project. First of all, clear the cache by running this command:
npx clear-npx-cache
If it does not work, use this and try again: Delete everything from this path.
C:\Users\Your_user_name\AppData\Roaming\npm-cache
On macOS (and likely Linux), it’s ~/.npm/_npx. You can drop it with:
rm -rf ~/.npm/_npx
Or try the command npm cache clean --force using administrator mode in your terminal. Now, just rerun your create command.
npx create-react-app your-app
Solution 3: Run this command
Just run this command one by one.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
npx create-react-app my-app
You will have to clear the npx cache to make it work.
You can locate the location of the folder where create-react-app is installed using npm ls -g create-react-app.
Also, to clear the cache, refer to this answer in How can I clear the central cache for `npx`?
I have solved this problem by running
$ npm uninstall -g create-react-app
then
$ npx clear-npx-cache
then
$ npm install -g create-react-app#5.0.0
and then finally it was able to use:
$ npx create-react-app my-app
(npx create-react-app#5.0.0 my-app) worked like a charm and its also much faster now then old react js
I followed the above suggestions but it didn't solve my problem.
Below steeps solved my problem
1- Learn npm cache folder path:
npm cache verify
This gives you npm cache folder path:
Cache verified and compressed (~\AppData\Local\npm-cache_cacache)
2- Go to"..\npm-cache" folder and delete everything
3- Cerate your project:
npx create-react-app my-app
I tried both and they all works fine. You can try any of them.
npx create-react-app#5.0.0 my-app
or
npx clear-npx-cache
Simply doing npx create-react-app#latest my-app-name worked for me.
I got same issue and I fixed it by running the following commands:
npx clear-npx-cache
npm cache verify
Go to"..\npm-cache" folder that you get its path from previous command and delete everything
npm install -g npm#8.3.0
npx create-react-app your_app_name
I was having the same problem and no matter what I tried (i.e. clearing cache, uninstalling -g create-react-app, etc..) nothing worked.
I had to use:
$ npm uninstall -g create-react-app
and
$ npm uninstall create-react-app
and then I was able to use:
$ npx create-react-app my-app
I know it seems simple but this was the only thing that worked for me.
If you still receive the same error after trying the other answers solutions try the following:
Go to the path where npm install packages globally.
On macOS or Linux it's usually: /usr/local/lib/node_modules
On Windows: C:\Users\USER_NAME\AppData\Roaming\npm\node_modules
Search for create-react-app folder and delete it. You might need to delete create-react-app related files from parent folder:
/usr/local/lib/
C:\Users\USER_NAME\AppData\Roaming\npm\
You may also try the 'npm root -g' command to get the path, however, for me the returned path wasn't the correct one for some reason.
If you clear the cache with "npx clear-npx-cache", exit your code studio and relaunch it again. Then create your app. It works like charm. The studio code need to lose the session first and that is why we need to exit the ms-code first and relaunch.
This command worked for me by clearing the npx cache
npx clear-npx-cache
I have resolved this issue with the following combination of commands
1. First clear the cache
npx clear-npx-cache
2. Now run this command, this will uninstall the old version, install the latest one and create a new app using npm
npm uninstall -g create-react-app && npm i -g npm#latest && npx create-react-app#latest my-app --use-npm
First update node to the latest version.download the package from website and reinstall it .then update npm.then try npx create-react-app#latest appname.
If you've previously installed create-react-app globally via npm install -g create-react-app, 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.
https://create-react-app.dev/docs/getting-started/
This solution working for me
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app my-app
If you're using npm>5 and still getting this error. This might be you have installed old npm and then updated. Tried to clear the npm cache with the below command. It should work like charm.
npx clear-npx-cache
To clear a cache in npm, we need to run the npm cache clean --force command in our terminal:
npm cache clean --force
npx clear-npx-cache
clean: It deletes all data from your cache folder.
npx have cache, you can run rm -rf ~/.npm/_npx to clear cache
I am getting this create React app error again and again even after doing the uninstall part.
npm uninstall -g create-react-app
up to date, audited 1 package in 570ms
found 0 vulnerabilities
npx create-react-app test-app
Need to install the following packages: create-react-app Ok to
proceed? (y) 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/
C:\>npm --version
8.3.0
C:\>node --version
v16.13.0
How can I fix this?
Try running npx clear-npx-cache to clear your npx cache and then running the npx create-react-app your-app command.
Also have a look at this answer on clearing the cache.
Additionally, it might be worth trying to force the latest version with:
npx create-react-app#latest my-app --use-npm
I have resolved with the following steps:
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app myapp
Solution 1: Force to the latest version
Just try to run the create command with force to the latest version. Just like this:
npx create-react-app#latest_version my-app --use-npm
And the latest version is 5.0.0 so just try this command:
npx create-react-app#5.0.0 my-app
Now, your error must be solved.
Solution 2: Clear the cache
You just need to clear your cache and then you can create a new React project. First of all, clear the cache by running this command:
npx clear-npx-cache
If it does not work, use this and try again: Delete everything from this path.
C:\Users\Your_user_name\AppData\Roaming\npm-cache
On macOS (and likely Linux), it’s ~/.npm/_npx. You can drop it with:
rm -rf ~/.npm/_npx
Or try the command npm cache clean --force using administrator mode in your terminal. Now, just rerun your create command.
npx create-react-app your-app
Solution 3: Run this command
Just run this command one by one.
npm uninstall -g create-react-app
npm cache clean --force
npm cache verify
npx create-react-app my-app
You will have to clear the npx cache to make it work.
You can locate the location of the folder where create-react-app is installed using npm ls -g create-react-app.
Also, to clear the cache, refer to this answer in How can I clear the central cache for `npx`?
I have solved this problem by running
$ npm uninstall -g create-react-app
then
$ npx clear-npx-cache
then
$ npm install -g create-react-app#5.0.0
and then finally it was able to use:
$ npx create-react-app my-app
(npx create-react-app#5.0.0 my-app) worked like a charm and its also much faster now then old react js
I followed the above suggestions but it didn't solve my problem.
Below steeps solved my problem
1- Learn npm cache folder path:
npm cache verify
This gives you npm cache folder path:
Cache verified and compressed (~\AppData\Local\npm-cache_cacache)
2- Go to"..\npm-cache" folder and delete everything
3- Cerate your project:
npx create-react-app my-app
I tried both and they all works fine. You can try any of them.
npx create-react-app#5.0.0 my-app
or
npx clear-npx-cache
Simply doing npx create-react-app#latest my-app-name worked for me.
I got same issue and I fixed it by running the following commands:
npx clear-npx-cache
npm cache verify
Go to"..\npm-cache" folder that you get its path from previous command and delete everything
npm install -g npm#8.3.0
npx create-react-app your_app_name
I was having the same problem and no matter what I tried (i.e. clearing cache, uninstalling -g create-react-app, etc..) nothing worked.
I had to use:
$ npm uninstall -g create-react-app
and
$ npm uninstall create-react-app
and then I was able to use:
$ npx create-react-app my-app
I know it seems simple but this was the only thing that worked for me.
If you still receive the same error after trying the other answers solutions try the following:
Go to the path where npm install packages globally.
On macOS or Linux it's usually: /usr/local/lib/node_modules
On Windows: C:\Users\USER_NAME\AppData\Roaming\npm\node_modules
Search for create-react-app folder and delete it. You might need to delete create-react-app related files from parent folder:
/usr/local/lib/
C:\Users\USER_NAME\AppData\Roaming\npm\
You may also try the 'npm root -g' command to get the path, however, for me the returned path wasn't the correct one for some reason.
If you clear the cache with "npx clear-npx-cache", exit your code studio and relaunch it again. Then create your app. It works like charm. The studio code need to lose the session first and that is why we need to exit the ms-code first and relaunch.
This command worked for me by clearing the npx cache
npx clear-npx-cache
I have resolved this issue with the following combination of commands
1. First clear the cache
npx clear-npx-cache
2. Now run this command, this will uninstall the old version, install the latest one and create a new app using npm
npm uninstall -g create-react-app && npm i -g npm#latest && npx create-react-app#latest my-app --use-npm
First update node to the latest version.download the package from website and reinstall it .then update npm.then try npx create-react-app#latest appname.
If you've previously installed create-react-app globally via npm install -g create-react-app, 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.
https://create-react-app.dev/docs/getting-started/
This solution working for me
npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app my-app
If you're using npm>5 and still getting this error. This might be you have installed old npm and then updated. Tried to clear the npm cache with the below command. It should work like charm.
npx clear-npx-cache
To clear a cache in npm, we need to run the npm cache clean --force command in our terminal:
npm cache clean --force
npx clear-npx-cache
clean: It deletes all data from your cache folder.
npx have cache, you can run rm -rf ~/.npm/_npx to clear cache
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 :)
I'm trying to create a new react app, but whenever I do npx create-react-app or npm init react-app, only the node_modules and a portion of package.json is installed.
npx create-react-app new-app
(https://imgur.com/iJDVQ3E) -> Current package.json and folder structure
Expected public folder and script run commands in package.json
I know it's been two months, but I came across this exact issue and found the next solution:
You only need to update your npm and node modules, they are outdated for us or missing something important and that is why we get no template folders. Try below command:
run npm install -g update-node
run npm update npm -g
These two commands should fix it, if not, let me know, maybe I forgot one command to tell you.
Uninstall react in case its installed globally by running the command "npm uninstall -g create-react-app". then run "npx install -g create-react-app".
npx comes with npm 52+ updated versions
tried using the above 2 commands and got created all the required folders under react app.
run npm install -g update-node
run npm update npm -g
I want to try React on my Mac, but I face some difficulties when using it.
I installed create-react-app globally with
npm install -g create-react-app
But everytime I create a new project I have a huge node_modules folder in my project folder. AFAIK I don't need node_modules folder in every project if create-react-app installed globally. So what's the problem?
When I tried to uninstall create-react-app to install it again (just to be sure I installed it globally) I get an error saying
npm remove -g create-react-app
Error: EACCES: permission denied, unlink 'usr/local/bin/create-react-app'
So what do I do in this case?
The node_modules folder you see for every project is node_modules for that specific project. This is how all javascript projects that use npm work. You don't want all the dependencies of every project installed globally. That would run into all kinds of issues with different versions of packages etc.
This error indicates that you probably ran npm install -g create-react-app as either root or as sudo like so: sudo npm install -g create-react-app. Try running sudo npm remove -g create-react-app and see if that works.
I couldn't use the new version of create-react-app with npx, so I tried to remove via the command npm uninstall -g create-react-app. After that when I checked it still has "installed". So I have removed manually
rm -rf /usr/local/bin/create-react-app
But everytime I create a new project I have a huge node_modules folder
in my project folder.
That node_modules folder store all the local dependencies for that particular project with specific versions as mentioned in package.json and its dependencies also. It is required for every project, unless all dependencies of your project are global and match the versions perfectly which never would be the case AFAIK.
Use npm uninstall -g package_name for removing package.
Also its better if you use npx for create new react projects. But this would only work properly if npm version is above 5 and you have to uninstall global create-react-app first.
npx create-react-app my-app
I hard similar issue with mine. I did
npm uninstall -g create-react-app
and it worked.
this may sound odd but it work many times
if this kind of error come than run code in your terminal
npm uninstall -g create-react-app
if not work than without any headache run
npm i create-react-app
in your root folder this will update the react app in your system after this untill next latest version you can enjoy with
npx i create-react-app my-app