React学习感悟——初始化一个React项目

DogJay 2019-01-31 前端技术 797人已围观

1.create-react-app是一个通过npm发布的安装包,在确认Node.js和npm安装好之后,输入下面命令创建。
  

npm install -g create-react-app

localhost:Projects dogjay$ npm install -g create-react-app
/usr/local/bin/create-react-app -> /usr/local/lib/node_modules/create-react-app/index.js
+ create-react-app@2.1.3
added 63 packages in 19.429s


   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.3.0 → 6.7.0    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯


2.安装结束后通过命令create-react-app my-app来创建一个项目名称为my-app的react项目
  

create-react-app my-app

localhost:Projects dogjay$ create-react-app my-app

Creating a new React app in /Users/dogjay/Documents/Projects/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...


> fsevents@1.2.4 install /Users/dogjay/Documents/Projects/my-app/node_modules/fsevents
> node install

[fsevents] Success: "/Users/dogjay/Documents/Projects/my-app/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
+ react@16.7.0
+ react-dom@16.7.0
+ react-scripts@2.1.3
added 2016 packages in 224.359s

Success! Created my-app at /Users/dogjay/Documents/Projects/my-app
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd my-app
  npm start

Happy hacking!


3.进入my-app项目目录后,通过命令:

npm start

You can now view my-app in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.14.84:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

4.运行成功后,自动打开浏览器显示React首页:


运行成功!项目初始化成功!

吐槽(0)

文章评论

    共有0条评论

    验证码:

文章目录