Contents
Prerequisites
- MacOS Catalina 10.15.4
- Node.js installed
Node.js update
n
There is one of the version control methods of Node.js.
Node.js is n
easy to update using commands, so n
install.
n
Installation of
Execute the following command.
npm install -g n
How to use n
n
You can check the latest version and recommended version of Node.js.
Execute the following command.
$ n --latest # The latest version
$ n --stable # The recommended version
Update to the recommended version. Execute the following command.
n stable
The following error may occur due to permission problem.
installing : node-v12.19.0
mkdir : /usr/local/n/versions/node/12.19.0
mkdir: /usr/local/n/versions/node/12.19.0: Permission denied
Error: sudo required (or change ownership, or define N_PREFIX)
In the above case sudo
, execute it obediently .
sudo n stable
install yarn
npm
But it can be executed, but yarn
it has more advantages, so yarn
install it.
Reference: What is npm What is yarn?
Execute the following command.
npm install -g yarn
Install create-react-app
I thought it was necessary to install it separately, but it yarn
seems that it is already installed when I installed it. Was present in the
following path create-react-app
.
/usr/local/bin
By the way, the above path is npm
the same as the installation location.
You can find out where to install npm with the following command:
npm bin -g
Create a React project
Start the project with the following command. The execution example is when the project name is sampleApp
used.
create-react-app sampleApp
Start React
create-react-app
A folder with the project name will be created in the directory where you started the React project . sampleApp
A directory called the above example will be created, so move it with the following command.
cd sampleApp
Execute the following command at the move destination to start the React project.
yarn start
Success when the following screen is displayed on the browser.
Discussion about this post