我是MEAN的新手,我只是在应用程序中内置了一些功能,但现在我正在尝试在iis服务器上部署。我获得了所有路径,但由于以下错误而未显示任何内容
Uncaught SyntaxError: Unexpected token < jquery.js:1
当我点击查看错误时,chrome dev工具会显示下面显示的索引文件,并指向第一行。任何人都知道我如何解决上面的错误?
的index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="vendor/toastr/toastr.css"/>
<link rel="stylesheet" href="css/site.css"/>
<link rel="stylesheet" href="vendor/angular-material/angular-material.css"/>
<link rel="stylesheet" href="vendor/angular-material-icons/angular-material-icons.css" />
<title>My App</title>
</head>
<body ng-app="fullStackScratch">
<div ng-view=""></div>
<footer>
<div layout="row" layout-align="center center">
<p> © Testing Footer</p>
</div>
</footer>
<script src="vendor/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="vendor/angular/angular.js" type="text/javascript"></script>
<script src="vendor/angular-resource/angular-resource.js" type="text/javascript"></script>
<script src="vendor/angular-route/angular-route.js" type="text/javascript"></script>
<script src="vendor/angular-animate/angular-animate.js" type="text/javascript"></script>
<script src="vendor/angular-material/angular-material.js" type="text/javascript"></script>
<script src="vendor/angular-aria/angular-aria.js" type="text/javascript"></script>
<script src="vendor/angular-material-icons/angular-material-icons.min.js" type="text/javascript"></script>
<script src="app/app.js"></script>
<script src="app/main/MainCtrl.js"></script>
<script src="app/account/login.controller.js"></script>
</body>
</html>
我刚刚添加了以下文件
route.js
var passport = require('passport');
module.exports = function (app){
app.get('/partials/*', function(req, res){
res.render('../../public/app/' + req.params[0]);
});
app.post('/login', function (req, res, next) {
var auth = passport.authenticate('local', function (err, user) {
if(!user){
res.send({success:false})
}
req.logIn(user, function(err){
if(err){
return next(err);
}
res.send({success:true, user:user})
})
});
auth(req, res, next);
});
app.get('*', function(req, res){
res.render('index');
});
}
server.js
var express = require('express');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var app = express();
var config = require('./server/config/config.js') [env];
require('./server/config/express.js')(app, config);
require('./server/config/mongoose.js')(config);
var users = mongoose.model('users');
passport.use(new LocalStrategy(
function (username, password, done) {
users.findOne({username: username}).exec(function (err, user) {
if(user){
return done(null, user);
}else {
return done(null, false);
}
})
}
));
passport.serializeUser(function (user, done) {
if(user){
done(null, user._id);
}
});
passport.deserializeUser(function (id, done) {
users.findOne({_id:id}).exec(function(err, user){
if(user){
return done(null, user);
}else {
return done(null, false);
}
})
})
require('./server/config/routes.js')(app);
app.listen(config.port);
console.log('Listening on port ' + config.port + '...');
express.js
var express = require('express');
var stylus = require('stylus');
var logger = require('morgan');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var passport = require('passport');
module.exports = function(app, config){
function compile(str, path) {
return stylus(str).set('filename', path);
}
app.set('views', config.rootPath + '/server/views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(logger('dev'));
app.use(cookieParser());
app.use(bodyParser());
app.use(session({secret: 'full stack from scratch'}));
app.use(passport.initialize());
app.use(passport.session());
app.use(stylus.middleware(
{
src: config.rootPath + '/public',
compile: compile
}
));
app.use(express.static(config.rootPath + '/public'));
}
答案 0 :(得分:1)
我猜你的应用程序如何路由,它正在尝试提供HTML文件而不是jquery。因此,当页面加载第一个HTML文件,然后它调用jquery文件时,浏览器呕吐无法解析第二个HTML文件(它认为是一个javascript文件)。