react项目 之 server基础搭建框架

类似于脚手架 一键生成后台项目

安装包

npm install express-generator -g

安装插件

在vscode中安装express插件

创建应用

express myapp

安装依赖

 cd myapp 
 npm install

启动

 npm start

修改端口

由于我在做react项目 默认3000端口占用 要修改端口

在./bin/www文件中

//var port = normalizePort(process.env.PORT || '3000');
var port = normalizePort(process.env.PORT || '4000');
app.set('port', port);

/**
 * Create HTTP server.
 */

var server = http.createServer(app);

修改后端响应式

修改后端代码时,时常需要重启,此时引入nodemon解决响应式问题

npm install -s-d nodemon

修改启动配置项

  "scripts": {
    "start": "nodemon ./bin/www"
  }
posted @ 2020-06-03 15:16  cc123nice  阅读(532)  评论(0编辑  收藏  举报