0
点赞
收藏
分享

微信扫一扫

React vscode 创建 react 项目流程

一、安装node

  1. 请在官网下载安装:​​https://nodejs.org/zh-cn/​​
  2. vscode 中 点击 ( ctrl + `) 调出终端
  3. 输入指令​​node -v​​,能显示版本号,说明 node 已经装好了
  4. 输入指令​​npm -v​​,能显示版本号,说明 npm 可以使用了

二、配置淘宝镜像

  • 输入指令:
  • ​npm install -g cnpm --registry=https://registry.npm.taobao.org​
  • 输入指令​​cnpm -v​​,能显示版本号,说明 cnpm 已经装好了

三、配置 ​​vscode​​(win10)

win7 无需配置

右击VSCode图标,选择​​属性​​​,选择​​兼容性​​​,勾选​​以管理员身份运行此程序​​​,最后点击​​确定​

React vscode 创建 react 项目流程_javascript

  1. vscode 中 点击 ctrl + ` 调出终端
  2. 输入命令:​​get-ExecutionPolicy​
  3. 输入命令:​​set-ExecutionPolicy RemoteSigned​
  4. 输入命令:​​get-ExecutionPolicy​
  • ​Restricted​​:表示禁止终端使用命令的
  • ​RemoteSigned​​:表示可以使用终端命令了

React vscode 创建 react 项目流程_javascript_02

四、全局安装脚手架

  • 在终端输入命令:​​npm install -g create-react-app​

React vscode 创建 react 项目流程_创建项目_03

  • 这需要等待一段时间,这个过程在安装三个东西
  • ​react​​: react的顶级库
  • ​react-dom​​: react在web段的运行环境
  • ​react-scripts​​: 包含运行和打包react应用程序的所有脚本及配置

五、创建项目

  • 先创建一个放置项目的文件夹​​www​
  • 在终端中使用​​cd​​指令跳转到这个文件夹
  • 创建项目指令:​​create-react-app your-app​​(your-app是项目名,可以自己取)

React vscode 创建 react 项目流程_版本号_04

  • 出现下面的界面,表示创建项目成功:

Success! Created your-app at /dir/your-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 your-app
npm start

Happy hacking!

  • 通过​​cd your-app​​命令进入目录
  • 运行​​npm start​​即可运行项目
  • 生成项目的目录结构如下:

├── README.md            使用方法的文档
├── node_modules 所有的依赖安装的目录
├── package-lock.json 锁定安装时的包的版本号,保证团队的依赖能保证一致。
├── package.json
├── public 静态公共目录
└── src 开发用的源代码目录

编写第一个 ​​react​​ 程序教程

Ref:​​(42条消息) React vscode 创建 react 项目流程【超详细】_一颗不甘坠落的流星的博客-​​



举报

相关推荐

0 条评论