免责声明:网站内容仅供个人学习记录,禁做商业用途,转载请注明出处。

版权所有 © 2017-2020 NEUSNCP个人学习笔记 辽ICP备17017855号-2

nodejs + react 前端框架使用笔记

hxy    2018年1月21日 23:58:18

1. 安装环境搭建:http://nodejs.cn/download/下载对应的版本

2. 国内使用npm速度较慢,可以使用淘宝定制的cnpm。

npm install -g cnpm --registry=https://registry.npm.taobao.org
npm config set registry https://registry.npm.taobao.org

3.  使用create-react-app快速构建开发环境

cnpm install -g create-react-app
create-react-app blog
cd blog

4. 修改默认端口为80:

Linux:

vim package.json
{
  "name": "blog",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.0"
  },
  "scripts": {
    "start": "PORT=80 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

 windows: 记事本打开package.json

{
  "name": "blog",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.1.0"
  },
  "scripts": {
    "start": "set PORT=80 && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

5. 浏览器访问:localhost

浏览: 1.7K

[[total]] 条评论

添加评论
  1. [[item.time]]
    [[item.user.username]] [[item.floor]]楼
  2. 点击加载更多……
  3. 添加评论