React+Node.js实战(1):开发环境搭建

安装Node.js# 官网下载Node.js安装包(LTS版)https://nodejs.org/zh-cn/# 执行安装并验证是否成功node --version# npmnpm -versionnpm -help# cnpmnpm install -g cnpm --registry=https://registry.npm.taobao.orgcnpm -version# yarn(速度快、安全、可靠)https://yarnpkg.com/npm instal
摘要由CSDN通过智能技术生成

安装Node.js

# 官网下载Node.js安装包(LTS版)
https://nodejs.org/zh-cn/

# 执行安装并验证是否成功
node --version

# npm
npm -version
npm -help

# cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm -version

# yarn(速度快、安全、可靠)
https://yarnpkg.com/
npm install -g yarn
yarn -version

# npm 与 yarn 常用命令对比
npm init               / yarn init
npm install            / yarn
npm install --save     / yarn add
npm install --save-dev / yarn add --dev
npm update             / yarn upgrade
npm uninstall          / yarn remove
npm install -g         / yarn global add
npm update -g          / yarn global upgrade
npm ls -g              / yarn global list
npm uninstall -g       / yarn global remove

创建node的http服务

const http = require("http");
const data = {
	code:200,
	data:{
		name: "hello node.js"
	},
	msg:"请求成功"
}

http.createServer((request,response) =>{
	response.writeHead(200,{"Content-Type":"application/json"});
	response.end(JSON.stringify(data));
}).listen(8096);

console.log("server runing at http://localhost:8096/");

 

React的安装

# 全局安装create-react-app工具
npm install -g create-react-app

# 使用create-react-app工具搭建react工程
create-react-app projectName

# 启动react
npm run start // 或者 npm start // yarn start

# 构建打包
npm build // 或者 yarn build

R

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值