Home > Web Front-end > JS Tutorial > How to download react package

How to download react package

藏色散人
Release: 2023-01-04 09:36:25
Original
9619 people have browsed it

How to download the react package: first install the react scaffolding; then install the Taobao cnpm command tool; then use the cd command to enter the project file directory; finally install it through the "npm init" and "cnpm install dependent package name" commands Just depend on the package.

How to download react package

The operating environment of this tutorial: Windows 7 system, react17.0.1 version, Dell G3 computer.

Recommended: "react video tutorial"

How to download react dependency package

1. Prerequisite

First ensure that node.js has been installed...

After the installation is completed, open the cmd command line and enter node -v and npm -v to view the version number. If it is displayed, the installation is complete.

2. Install react scaffolding

Enter in the cmd command line: npm install -g create-react-app and wait for its installation

3. Create a new React project

The created project is installed in the user directory by default. If you want to change the directory, you can refer to the following command:

Enter in the cmd command line: d: (select the D drive)

In the cmd command line Enter: cd d:reactDemo (enter the specified folder in the D drive)

Execute the new project command: create-react-app my-new-app ("my-new-app" is your project Root directory folder name)

Continue to wait for a long time....Remember...don’t panic

4. Install Taobao cnpm command

npm to get some It takes time. It is recommended that you use the Taobao team's cnpm

and enter in the cmd command line:

npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy after login

Enter cnpm -v. If the input is normal and no errors are reported, it means that the installation has been successful

5. Install the required dependency packages

Enter in the cmd command line:

cd d:reactDemo my-new-app  (进入你新建的项目文件路径)
Copy after login

Continue cmd as follows:

npm init   (然后一路回车)
cnpm install --save react react-dom       ( 在该目录下导入react和react-dom)
cnpm install --save  react-router-dom   (react路由,以后会用到)
Copy after login

Continue waiting...

6. Start the project

Confirm that the cmd directory is under the root directory of your project: d:reactDemo my-new-app

Start the project: npm start It will automatically The web page window of localhost:3000 pops up

If you want to close the project, just close the CMD window directly, or use Ctrl C, enter Y and exit

The above is the detailed content of How to download react package. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template