express+gulp+browserSync配置问题

首先简述下这个问题的意义:

搭建express+bs+gulp的目地是实现mock server

其次是想要达到的效果:

通过一行命令 gulp,实现mock server的启动和bs的监控

配置文件:

use strict let gulp = requiregulp;
let sass = requiregulp-sass;
let jshint = requiregulp-jshint;
let minify = require"gulp-clean-css";
const browserSync = require"browser-sync".create;
let reload = browserSync.reload;
let ts = require"gulp-typescript";
let tsProject = ts.createProject"tsconfig.json";
let nodemon = require"gulp-nodemon"; let paths = ["src/*.html", "src/*/*.html", "src/*/*/*.html"];
let watchPaths = ["src/*", "src/*/*", "src/*/*"]; gulp.task"html", function { return gulp.srcpaths .pipegulp.dest"dist"
} gulp.task"ts", function { return tsProject.src .pipetstsProject .js.pipegulp.dest"dist/js";
} gulp.task"js", function { return gulp.src"src/*.js" .pipejshint .pipegulp.dest"dist"
} gulp.task"sass", function { return gulp.src"src/sass/*.scss" .pipesass .pipeminify .pipegulp.dest"dist/css"
} gulp.task"reload", function { reload[dist/*/*.*, dist/*, dist/*/*.*];
} gulp.task"server", function { nodemon{ script: app.js, ignore: [.vscode, .idea, node_modules], env: { NODE_ENV: development } } .onstart, function { browserSync.init{ proxy: "localhost" // server: { // baseDir: "localhost/router/dist", // index: "index.html" // } } }
}; let tasks = [html, js, sass,ts,reload]; gulp.task"default", ["html", "js", "sass","ts", "server", "reload"], function { gulp.watch[src/*/*.*, src/*, src/*/*/*], tasks;
}

过程中的问题:

terminal下输入gulp,浏览器自动打开localhost:3000,出现403Forbidden nginx/1.8.0

terminal输入后是这样的:

浏览器是这样显示的:

随便更改个地方会重启,提示报错

其它

目录结构通过express生成的,做了部分修改

app.js文件(改动处已标记)

package.json文件

发表评论

电子邮件地址不会被公开。 必填项已用*标注