How can I fix an issue with create-react-app where only node_modules, package.json, and package-lock.json are created? - reactjs

I know there are other previous posts on this. However, they are from a few years ago, making them somewhat outdated. The issue I am having just started as of May 2, 2022.
If I run npx create-react-app my-app, the only thing that gets created is the folder and two files mentioned in the question title. I've spent over an hour trying previous solutions to other questions and using other sources, but the issue is still not resolved. I was wondering if anyone could help me?
Thanks

This is hard for me to answer without knowing the stack you have installed on your computer, however based on the information provided, you could be on your way!
From your terminal, I would try to navigate into the new app by:
`cd my-app`
Then, to start the server, run:
`npm start`
Here are some resources that I think will help you in your scenario:
https://reactjs.org/docs/create-a-new-react-app.html
Good luck buddy!

Related

React-navigation installation error(following official docs). Unable to resolve module #react-navigation/native-stack

There are a bunch of questions already covering this exact error, but I've been through all of them, and so far none of the answers have worked for me. Platform is MacOS
Here is the error:
Steps to reproduce
(Following official React Navigation docs https://reactnavigation.org/docs/getting-started/):
Create a new expo managed app
expo init my-app
Navigate to directory
Start the app
expo start
**** At this point everything starts and works correctly ****
Install reactnavigation(follow official docs https://reactnavigation.org/docs/getting-started/ )
yarn add #react-navigation/native
Install dependencies
expo install react-native-screens react-native-safe-area-context
Wrap the code with a Navigation container (per the docs)
Start the app
expo start
**** App no longer works. Fails with the error I posted earlier ****
Things I've tried that haven't worked
The instructions that the error message provides (though I skip step 1, as I don't have watchman watches installed). Main thing here that I would expect to work is the deletion of node_modules and yarn.lock, but no luck :(. Same with deleting cache
using yarn add to add the dependencies instead of expo install
using npm to install everything
updating expo-sdk (I'm already on latest)
reinstalling everything
So, I actually was able to answer my own question in the process of writing it. I often do this, as I make sure to spend several hours trying to debug in the process of writing the question and making sure I've covered everything I can think to try.
Not sure of official self answer etiquette, but this was a pretty frustrating error for me, so I figure I'll post what worked for me here in case it can help anyone else in the future.
Answer:
The issue for me had nothing to do with the code or app itself, but rather the IOS simulator. Force quitting the simulator and restarting resolved the error. It seems that simply ctrl^c -> expo start -> i -> r is not enough to clear the internal state of the simulator.
There was actually even a clue in the error message itself, but I missed it because the error looked so similar to the one I was expecting. The clue was in the name of the module it was unable to resolve "#react-navigation/native-stack". In my reproduction steps, I was only using the NavigationContainer, as I was trying to get that working before installing any of the Navigators and trying to use those.
Why was it trying to resolve the native-stack navigator? I'm not 100% sure, but my guess is that there was some kind of cache in the simulator that wasn't being cleared properly. Why do I think that?
This problem started with me trying to use a native-stack navigator in another app I'm working on. I quickly ran into this error, and figured the best way to debug would be to spin up a brand new blank app and try to get ReactNavigation working in there. I started with just navigation package and NavigationContainer itself, and once I couldn't even get that working, I assumed the problem was with the base react-navigation package installation. I failed to notice that it was still trying to resolve that native-stack navigator.

how to properly push to github using build? [duplicate]

This question already has answers here:
Blank page after running build on create-react-app
(17 answers)
Closed 1 year ago.
I'm a newbie to both git and AWS.
I bought a domain using AWS and have connected it to a Github repository.
I pushed the app to repository without initiating an npm run build.
After realizing that the website was showing the readme.md instead of the index.html which is inside of the public folder (not that that's working either), I decided to try to run npm run build and push that to the github repository, thinking that maybe that could fix my issue.
The problem I ran into was that /build is ignored inside .gitignore.
So I'm not sure if I should remove /build from .gitignore or find a work around, or something else I'm not aware of?
I would really appreciate some explanation from someone on that issue.
Thank you in advance.
So, there are 2 different things that we must break down from this question . One related to git itself and other is to the app build.
.gitignore tells git which files (or patterns) it should ignore. It's usually used to avoid committing transient files from your working directory that aren't useful to other collaborators, such as compilation products, temporary files IDEs create, etc. It basically does keep track of the specified file or directory
More related to that can be found in here:
http://git-scm.com/docs/gitignore.
Now, going to the original problem (which is building your app) github does have a CICD pipeline called github actions which essentially allows you to create a workflow based on a template that can help building your app. Therefore the build can be done when your is code is pushed, without have to send unnecessary files to your remote repository from your local npm run build. (You can find more related to this subject in this link:
https://docs.github.com/en/actions/guides/building-and-testing-nodejs?learn=continuous_integration)
That doesn't necessary solves your issue with your App (because we are not discussing anything related to coding), but if your problem is just building the app that would be a starting point.
My other recommendation would be also to check more on how git/github actually works and how you can take advantage of these systems in the future to deploy/control your code.
Hopefully this can help!
Found the answer to my question here. Thanks for the help guys.
Blank page after running build on create-react-app

How to check if a create-react-app project has been ejected or not?

I'm working on a project built by someone else. I know it was bootstrapped by create-react-app because it says so in README.md.
However, I'm not sure if it has been ejected or not. There are many posts out there teaching you how to actually eject it, but I failed to find a way to check it in the first place. Any help is appreciated!
Some immediate giveaways that a create-react-app project has been ejected:
The dependencies field in package.json no longer contains react-scripts. Instead, it is populated with many additional packages like Babel, Eslint, Jess, Webpack and various Webpack loaders.
The absence of eject script.
The start, build and test no longer follows this format react-scripts start, react-scripts build etc.
A new directory named config appears.
Just sharing because you may or may not see all of these signs in your project as they were probably ejected a long time ago. I hope no one will spend two hours wondering why a certain package didn't work only to discover that the project has been ejected and the package only works with unejected ones.
Many thanks to #YuryTarabanko!
So I tried creating another project using CRA and ejecting it. Right after the ejection, a new directory called config popped up and there were some modifications in other directories, too.
Then I took a look at the project I'm actually interested in. The config directory is right there, with a structure similar to that config dir in the new project that popped up after the ejection. So I'm sure this project has been ejected, too!
Edit:
As Yuri pointed out in the comment:
The most noticeable difference IMHO would be the absence of eject command in package.json#scripts section though ;)
I somewhat agree with the script in package.json, but it could have easily been removed. If the project is in a repo, you should be able to look at the history of a few files to be certain.

Just to clear the air once and for all, how exactly do you update npm packages in your working repository?

Apologies if this is a basic question, I 'somewhat' know how to do it but at the same time do not and have scoured the internet for answers and none of the solutions seem to work.
Specifically, I am asking in regards to when github tells you that you have a security alert and must update a dependency in your package-lock file. How exactly do you solve this in your working repository? I am trying to simply update the necessary packages in my React.js repository and then push the package-lock file onto the master branch but cannot figure out a simple quick solution to do this.
Thank you very much in advance.
You'll want to use npm update <package> --save, that will update to the newest version and save that version to your package.json
https://docs.npmjs.com/cli/update.html

ReactJS, create-react-app gets an error

I run from my console the "create-react-app practise1" command but it gets an error.
I couldn't understand why. Can you help me?
Normally I used it before as "create-react-app react-complete-guide" and this command had worked at that time.
I share all the codes that i get as screenshot.
Thank you,
My Console screenshot
You should probably have text like this in your error:
error Received malformed response from registry for "timed-out". The
registry may be down.
Currently part of NPM is down. https://status.npmjs.org/
Identified - Several packages including "require-from-string" are currently unavailable. We are aware of the issue and are working to restore the affected user and packages. Please do not attempt to republish packages, as this will hinder our progress in restoring them.
Jan 6, 19:45 UTC
This isn't a problem directly with create-react-app itself but one of it's dependencies it needs, require-from-string. And that issue is coming from the npm registry itself, and temporarily, not create-react-app. See this about the npm registry status and this issue from create-react-app itself:
What you can do, is if you have another project bootstrapped with create-react-app, you can copy it and make changes as neccessary for starting a new project. Or - you can wait until this issue from the npm registry is resolved. This is what happens when modern projects take a large number of dependencies - if a few of those dependencies aren't available, the whole project can have problems.

Resources