create-react-app not creating certain folders - reactjs

I am having trouble with creating a react app (windows)
NPM Version: 6.14.11
Node version: 14.15.4
Whenever I run npx create-react-app my-app I am missing the folders that are usually created. I have my node_modules folder and my package and package-lock JSON files, but I am missing everything else (missing src, public, etc).
When I try to run npm start, the script isn't found.
I have already read the Getting Started guide where it says to try npm uninstall -g create-react-app and I have already updated npm and node. I still cannot get these folders to populate. Any ideas?

Related

Why React npm start return error for webpack-dev-server 3.11.1?

I have the following error with npm start in my React application:
The react-scripts package provided by Create React App requires a dependency:
"webpack-dev-server": "3.11.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:
C:\Users\Username\node_modules\webpack-dev-server (version: 3.11.0)
Usually I fixed this type of issue by running the following code: npm install react-scripts#latest.
But now it seems like that React is not updated yet to the latest webpack-dev-server
Now the question is how to fix that. By the way, I use npx create-react-app for my project, Thanks!
I have write following commands in react project
Open project in command prompt
npm uninstall -g webpack-dev-server
remove web-dev-server folder from node_modules(C:/Users/UserName/Node_Modules)
npm i -g webpack-dev-server#3.11.1
remove package-lock.json and write npm install
after it your react project may be start by npm start
First, remove the node_modules folder and yarn-lock or package-lock.json file.
And, then add this line in your .env file:
SKIP_PREFLIGHT_CHECK=true
Now you can do npm start or yarn start after re-installing the packages. It should work.
Explanation:
For some reasons, you have two versions of webpack-dev-server installed in your project's node_modules. By setting SKIP_PREFLIGHT_CHECK=true in .env file, we are telling npm to ignore such version issues.
Check if node_modules and package-lock.json are present in your home folder, instead of your project folder. If yes, delete those two folders and then go for npm start.

Unable to create new react app with npx create-react-app

I am trying to create new react app with npx create-react-app [name] command. But I get following error:
error Couldn't find package "#babel/plugin-transform-flow-strip-types#7.9.0" required by "babel-preset-react-app#^9.1.2" on the "npm" registry.
Each time it is saying some package could not be found on npm registry (not only #babel/plugin-transform-flow-strip-types#7.9.0 this package).
I have also updated my npm and npx, but no success.
You can try deleting the .npmrc file located in Users/you/.npmrc and run the command again, seems there is a bug with npm and this is a workaround

On npm start npm ERR! A complete log of this run can be found in:

On npm start I am getting
npm ERR! A complete log of this run can be found
in:C:\Users\asus\AppData\Roaming\npm-cache_logs\2019-07-05T11_54_44001Z-debug.log
How can I solve this, please help me out
Type this command and your problem will be solved.
npm set registry http://registry.npmjs.org/
You should be in the right folder before you start react. Your main folder which includes public,src, package.json files should be targeted with changing directory and then npm start can be used
I was facing the same problem. And this is how I solved it.
Little scenario here.
I downloaded the other's project from GitHub ; did not started from the scratch. I extracted the zip. It created the folder react-stop-watcher with another folder react-stop-watcher.
Initially I hit the npm start command in
C:\Users\Lenovo\Downloads\react-stopwatch-master\
It throw the same npm ERR!. We need to get into
C:\Users\Lenovo\Downloads\react-stopwatch-master\react-stopwatch-master\
instead And then hit
npm install
npm start
And now my project is up and running.
I faced the same problem.
So, first I uninstalled the previous version by using
npm uninstall -g create-react-app
to ensure npx always uses the latest version.
And then reinstalled with the same code procedure:
npx create-react-app my-app
cd my-app
npm start
And it worked!
Most probably I think you are using mysql but you not install mysql or not import the mysql.
I am also getting the same error but i resolve it by installing and importing the mysql.
try this
npm install mysql
import mysql in the file
var mysql = require('mysql');
change the parent name u have give space between them like
"hello world"
"hello_world" folder name should be this.
Basically, the error is just because of a network issue, might be your internet connection off or low internet connection try after some time that definitely works.
# to create project
npx create-react-app projectName
# to run server
npm start
Just follow this code
npm install
Then
npm audit fix
Add SKIP_PREFLIGHT_CHECK=true to a .env file and that's it. Will solve it if you are using react
cd to your project directory(myapp) where you have node_modules, public, src etc and try npm run.
An error is coming coz you are not in the correct directory. Simply use cd(react project name) i.e.in may case its cd my-app(that I created using npm create-react-app my-app) and then simply run npm start
enter image description here
First You need to Delete all logs files in you Node cash folder
*C:\Users\asus\AppData\Roaming\npm-cache_logs*
After that delete the package-lock.json file
run npm install and run your project
just type the following in terminal:-
pwd,cd NameOfFolder

did i install create-react-app incorrectly?

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

Issue with babel-jest dependency when running npm start in a React app

All I am doing is running create-react-app and cd'ing into the app, then trying to run npm/yarn start. I get the following error/output/log. I have walked through all of the suggested steps. The only thing that works is the SKIP_PREFLIGHT_CHECK=true in my .env as the last resort for both
Yarn and npm. I have recently updated to Mojave and had to reinstall my Xcode if people have had a similar experience.
Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start
> react-express-graphql-app#0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "23.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:
/Users/jasonspiller/node_modules/babel-jest (version: 23.4.2)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Users/jasonspiller/node_modules/babel-jest is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-jest in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-express-graphql-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-express-graphql-app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jasonspiller/.npm/_logs/2018-10-30T23_09_42_358Z-debug.log
I just had the same problem. For some reason the package ended up in a node_modules directory in my home directory. It also gave me the exact same error for the jest package.
I'm not sure of the correct way to fix this as npm uninstall -g babel-jest and yarn global remove babel-jest do not do anything.
I fixed it by just blowing away the folders that cause the problem:
bash
rm -rf ~/node_modules/babel-jest ~/node_modules/jest
It would be great to know how those packages ended up there, and the proper way of getting rid of them, but for now just deleting the folders is enough to get CRA dev server running without skipping the preflight check.
This problem can occur if there is node_modules in a parent directory of the folder where you run the application. I solved the problem by deleting the node_modules directory.
I too faced a similar problem and was able to resolve the issue following below steps.
Create a .env file in your project root directory and add the following statement
SKIP_PREFLIGHT_CHECK=true
Save the file
Remove node_modules, yarn.lock, package.lock
Then reinstall node_modules with
npm install
This should work
The problem seems to have reappeared in create-react-app 3.0.0.
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "24.7.1"
As abisuq pointed out in https://github.com/facebook/create-react-app/issues/6756#issuecomment-489562571 adding a version resolutions into package.json temporarily fixes the problem.
"resolutions": {
"babel-jest": "24.7.1"
},
Update: It has been fixed in create-react-app 3.0.1. If upgrading is an option you can run
npm install --save --save-exact react-scripts#3.0.1
or
yarn add --exact react-scripts#3.0.1
run: npm ls babel-jest
got : babelk-jest#24.7.1 & babel-jest#24.8.0 installed
this means install tow babel-jest with diff version
run:npm uninstall babel-jest#24.8.0 fix my issue
I had this issue and finally solved it easily.
As probably you know, when we use create-react-app, Jest is configured by default and you don't need to install Jest (when we use Webpack, we can install Jest). So, if you use Create-react-app and install Jest by mistake:
Firstly uninstall it (remember that if you use: (npm install --save-dev jest), you can remove jest directly from Package.json or use: (npm uninstall --save-dev jest)
Delete package-lock.json (not package.json)
Delete the node_modules
npm install
Now you don't receive an error and you can easily use: (npm start) or (npm test)
Also, It is worth mentioning that I installed the following tools to write my test in React component:
(npm install --save-dev enzyme enzyme-adapter-react-16 jest-enzyme)
and wrote my test by using jest and enzyme. Then I easily use: (npm test)
Good Luck!
Ok I finally found a solution after trying everything. Here is what finally worked:
First of all, read the error message in the cmd from the beginning. They'll tell you what module is causing the problem. You probably have an older version installed on your computer. Example: babel-jest version 2.4.4
Go to your Node.js folder c:/Users/(your user)/node_modules and find that module and simply delete it.
Go back to the cmd and run npm start. You might get the same error. But it'll be for a different module. Just delete it the same way and repeat until it runs.
I fixed the issue by removing the node_modules folder and package-lock.json file from a folder that was higher than the root of the project. I had installed node_modules accidentally in a higher folder.
I had:
desktop/code/node_modules (remove this to fix)
desktop/code/package-lock.json (remove this to fix)
desktop/code/project/node_modules
desktop/code/project/package-lock.json
I was having this issue as well. When I tried to run the client using npm start, the error would occur, telling me that it required babel-jest: ^24.9.0.
I noticed that in my client, babel-jest was version ^24.9.0, but in my server, I had "jest": "^26.6.3".
All I had to do was change "jest": "^26.6.3" to "jest": "^24.9.0" in the server side source code, delete my package-lock.json as well as node_modules in server, npm install again, and good to go!
At first I installed these (my react version was "^17.0.2")
npm install --save-dev jest
npm install --save-dev enzyme enzyme-to-json
npm install #wojtekmaj/enzyme-adapter-react-17
After that, I had the same problem.
Then I did these steps :)
Added '.env' file in my project root directory and add:
SKIP_PREFLIGHT_CHECK=true
Removed node_modules & package.lock
npm install
npm start
I had the exact same issue.
What I tried was to create the react app outside the directory that had the node_modules folder.
After that, started the app with yarn start and didn't have the error anymore.
I had the same problem, and I fixed this issue. For some reason because node_modules on my local. I removed babel-jest & jest. After that, npm start. I'm not sure this solved incorrect but this correct for me.
I solved this issue by deleting the node_modules folder and package-lock.json file I accidentally had installed in the root of my user.
For me in Mac the path was:
Macintosh HD -> Users -> "My-user-name"
I discover that might be the problem by running npm ls babel-jest on terminal. That showed me that there was another babel-jest up in the tree.
After deleting these two I did npm install in my app where I previously had deleted the node_modules folder and package-lock.json.
Now it's running ok !
I fixed this by deleting node_module folder in the project directory
try this command and see which packages create conflicts in versions.
npm ls babel-jest
replace the conflicted packages with updated one of that package.
I tried all of written solutions above. But none of them worked. I solved problem by deleting "C:\node_modules" folder.
Then delete project node_modules and package-lock.json. Finally, npm install and start again. And it worked.
My react-scripts version is 4.0.3. The problem suddenly happened after installing a private remote package, which installed multiple babel packages in my project root's node_modules. I solved this by installing the problematic packages on the project root's level explicitly, so that they match the versions reported in the preflight check.
Following addings fixed it in my case. Your needed packages and versions may differ, you have to check the preflight report.
yarn add babel-jest#^26.6.0
yarn add babel-loader#8.1.0
For me its still a workaround, but i prefer this way instead of removing something in node_modules manually as suggested in https://stackoverflow.com/a/53093421/4840661.
This is the approach without deleting node_modules:
I recieved error like:
The react-scripts package provided by Create React App requires a dependency:
"jest": "26.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of jest was detected higher up in the tree:
First check the versions using:
npm ls babel-jest
In my case output was like this:
jest#27.0.3
└─┬ #jest/core#27.0.3
└─┬ jest-config#27.0.3
└── babel-jest#27.0.2
After that uninstall babel-jest by
npm uninstall babel-jest
(When you see the single version of babel-jest,otherwise go as versions as follows)
npm uninstall babel-jest#27.0.2
Then install required dependencies using
npm i babel-jest#version jest#version
(Where version is the one come in 1st point)
This works for me like a charm. Hope this solves you too.
Got this error in the netlify ci, here's the fix that worked for me:
this method works for any lib i got a error for eslint instead of babel-jest.
force the error to be shown by npm i -s #babel-jest/VERSION --force
replace VERSION with whatever version shows in the error(23.6.0 in this case),
the correct error message will be shown locally
use https://www.npmjs.com/package/npm-check-updates to upgrade your package.json flie with the correct versions
run ncu -u in dir of package.json after installing the npm package
globally
finally do a npm ci
this will delete the package-lock and node_modules and install the new versions based on the second step
this work for me.
clear caches in npm or yarn
remove node_modules and lock files
create .env file
add " SKIP_PREFLIGHT_CHECK=true " to an .env file in your project.
my issue was that I have both frontend and backend that I am running concurrently. I installed jest to my root project (for backend) and I guess there is collision with pre-installed react jest. I just uninstalled jest from backend and voila I am happy now. I don't have anything related with babel.
i had the similar problem and wasted my 2-3 days
The easiest way to solve this problem is :
1.go outside of src, and create .env file.
2.Inside .env file, just write this single line and save it:
SKIP_PREFLIGHT_CHECK=true
3.then npm start
Hope this helps, Happy coding!!!

Resources