- Create-react-app Not Working Macbook Pro
- Npx Create-react-app Not Working Mac
- Update Create React App
- Create A New React App
- Create-react-app Not Found Mac
Starting a new React project is very complicated, with so many build tools. It uses many dependencies, configuration files, and other requirements such as Babel, Webpack, ESLint before writing a single line of React code. Create React App CLI tool removes all that complexities and makes React app simple. For this, you need to install the package using NPM, and then run a few simple commands to get a new React project.
The create-react-app is an excellent tool for beginners, which allows you to create and run React project very quickly. It does not take any configuration manually. This tool is wrapping all of the required dependencies like Webpack, Babel for React project itself and then you need to focus on writing React code only. This tool sets up the development environment, provides an excellent developer experience, and optimizes the app for production.
Requirements
The Create React App is maintained by Facebook and can works on any platform, for example, macOS, Windows, Linux, etc. To create a React Project using create-react-app, you need to have installed the following things in your system.
Enter create-react-app, the tool recently released by Facebook's engineering team that allows you to spin up a brand new React application in just a few seconds. They do this by wrapping all of the normal dependencies (babel, etc) so you can just focus on writing React code itself. Now go the the folder where you want to create-react-app. All will work fine! NVM transfers permission rights from root to user. So you never have to use ‘sudo’ to install any npm. Enter create-react-app, the tool recently released by Facebook's engineering team that allows you to spin up a brand new React application in just a few seconds. They do this by wrapping all of the normal dependencies (babel, etc) so you can just focus on writing React code itself. It's an excellent piece of software and is already becoming the. The solution was to unset the HOST environment variable on the command-line before you issue 'yarn start' so that it would use 'localhost' to start the server instead of the mac's name. THEN, when I went to the browser and typed in 'localhost:3000' it worked just fine and I could see my react app. Actually, I npx create-react-app my-app one month ago, and it works! But today, I can create a new one but cannot run it. But today, I can create a new one but cannot run it. Plus, I changed my hosts yesterday, just add a domain, so it seems not the hosts problem.
- Node version >= 8.10
- NPM version >= 5.6
Let us check the current version of Node and NPM in the system.
![Pro Pro](https://cdn-images-1.medium.com/max/800/1*m-k5hilRmrBndayiiXgh_g.png)
Run the following command to check the Node version in the command prompt.
Run the following command to check the NPM version in the command prompt.
Installation
Here, we are going to learn how we can install React using CRA tool. For this, we need to follow the steps as given below.
Install React
We can install React using npm package manager by using the following command. There is no need to worry about the complexity of React installation. The create-react-app npm package manager will manage everything, which needed for React project.
Create a new React project
Once the React installation is successful, we can create a new React project using create-react-app command. Here, I choose 'reactproject' name for my project.
NOTE: We can combine the above two steps in a single command using npx. The npx is a package runner tool which comes with npm 5.2 and above version.
The above command will take some time to install the React and create a new project with the name 'reactproject.' Now, we can see the terminal as like below.
The above screen tells that the React project is created successfully on our system. Now, we need to start the server so that we can access the application on the browser. Type the following command in the terminal window.
NPM is a package manager which starts the server and access the application at default server http://localhost:3000. Now, we will get the following screen.
Next, open the project on Code editor. Here, I am using Visual Studio Code. Our project's default structure looks like as below image.
In React application, there are several files and folders in the root directory. Some of them are as follows:
- node_modules: It contains the React library and any other third party libraries needed.
- public: It holds the public assets of the application. It contains the index.html where React will mount the application by default on the <div></div> element.
- src: It contains the App.css, App.js, App.test.js, index.css, index.js, and serviceWorker.js files. Here, the App.js file always responsible for displaying the output screen in React.
- package-lock.json: It is generated automatically for any operations where npm package modifies either the node_modules tree or package.json. It cannot be published. It will be ignored if it finds any other place rather than the top-level package.
- package.json: It holds various metadata required for the project. It gives information to npm, which allows to identify the project as well as handle the project?s dependencies.
- README.md: It provides the documentation to read about React topics.
React Environment Setup
Now, open the src >> App.js file and make changes which you want to display on the screen. After making desired changes, save the file. As soon as we save the file, Webpack recompiles the code, and the page will refresh automatically, and changes are reflected on the browser screen. Now, we can create as many components as we want, import the newly created component inside the App.js file and that file will be included in our main index.html file after compiling by Webpack.
Next, if we want to make the project for the production mode, type the following command. This command will generate the production build, which is best optimized.
Windows Subsystem for Linux is the tool that was released by Microsoft to get a full UNIX system inside of Windows. WSL opens up a bunch of new capabilities for developers using Windows, and is pretty fast for normal everyday web development tasks.
In this post, I cover some first impressions from my experience installing and running WSL2 (Windows Subsystem for Linux) in my dev workflow.
I haven’t done any exhaustive, scientific, or precise tests by any means. What I have found though is that WSL is about 5 times faster for everyday web development tasks like npm or yarn.
Maltego app for mac. Also, hot reloading and working with create-react-app or the vue-cli is faster!
Create-react-app Not Working Macbook Pro
Read on for installation, getting started, gotchas, and specific timing on
npx create-react-app
What does WSL 2 bring?
This is the process I went through and the surprises I encountered while installing.
Installing WSL2 on Windows 10
Microsoft now has stable documentation on how to install WSL and update to WSL2.
To get up and running, follow the guide above through to the point where you set up a new linux distribution.
Checking if the Install Worked
The following command will show us what distros we have installed and what version they are on:
Installation Failure
If you already had Ubuntu installed on WSL 1, you may have to completely uninstall and reinstall it.
If your computer is having trouble running the update command (like my computer), then you may want to completely uninstall and reinstall your distro.
I went into the Windows settings under Apps > Apps and Features and uninstalled Ubuntu:
Then I made sure that the default version I wanted for all new installs was version 2:
Now we can go into the Windows Store to install it:
Once we’re installed, then we can check to be sure that version 2 was installed. Open up Powershell and run:
Running WSL
You can open up Windows Terminal and use the Ubuntu dropdown:
Alternatively you can open up either
cmd
or Powershell
and run:Gotchas with WSL 2
Speed when transferring between file systems is a little slow right now. That’s not a worry for me since I never transferred. I worked solely inside of my Windows files which were mounted into the Linux system.
Here’s a guide on User Experience changes from WSL 1 to WSL 2. The two big gotchas are:
- Move your files into the Linux file system instead of your Windows system
- You will need to access localhost apps like
[localhost:3000](http://localhost:3000)
via an IP address like192.168.28.2:3000
Move all files into Linux
To take advantage of all the new speed improvements in WSL 2, our files will need to be moved into the Linux filesystem.
The best way to figure out where to move your files is to find the home directory in Linux, then open it in Windows explorer. Run the following:
Notice the path as a Network path:
We can now move our files from our Windows folders into this new networked folder. We’ll be able to access it from our WSL and interact with it as if it were still in the same Windows files.
For instance, we can install Node using a tool like n and then run
npm start
to run a local server for let’s say a React app.Network Isn’t localhost Yet
When we create an app using create-react-app or the vue-cli, we will usually run a command like
yarn start
or yarn serve
to run a local server.Normally we would be able to check on our application right in our browser using
[localhost:3000](http://localhost:3000)
for React or [localhost:8080](http://localhost:8080)
for Vue.In the early stages of WSL 2, we can’t use localhost. We need to use an IP since Linux is inside a VM.
To access your application currently, we will use an IP.
Notice the
192.168.28.2:3000
. We’ll use that to access our application:A Quick Comparison and Speed Test
This entire exercise was to get a setup that was faster than the previous one. Let’s see if this setup is any faster!
I don’t have anything too scientific. I’ll go back and run more tests, but I was frustrated how long a new React app took WSL 1 to make.
For now, our test will be to run npx create-react-app my-new-app.
We’ll be comparing the following machines. I know this isn’t scientific at all. I wish I had more computers with similar setups. I wish I had done these speed tests before I upgraded to WSL 2. Oh well. We have what we have!
- My desktop machine (super powerful, more than the laptops for sure)
- Surface Book 2 15' i7
- MacBook Pro 15' 2015
Npx Create-react-app Not Working Mac
Here are the numbers I got from running the test a few times on each platform.
Update Create React App
- Surface Book 2 WSL 1: 257 seconds
- Surface Book 2 WSL 2: 52 seconds
- 2015 MacBook Pro: 45 seconds
- 2018 MacBook Pro: 38 seconds
While still not as fast as the latest MacBook Pro, WSL 2 has made significant improvements over WSL 1.
What’s Next?
We’ll keep getting updates and I’ll keep testing to see if performance is improving. I would love to get to a point where WSL 2 on Windows could be as fast as a 2018 MacBook Pro.
I love both Windows and Mac platforms and with WSL 2, my tools on both platforms has gotten even closer:
Create A New React App
- Chrome
- VS Code
- Terminal
Create-react-app Not Found Mac
Happy coding!