Unexpected Token < while running Mean Stack application

狂风中的少年 提交于 2020-01-17 01:55:11

问题


I am following Plurasight video tutorials on creating mean stack application. http://pluralsight.com/training/Courses/TableOfContents/building-angularjs-nodejs-apps-mean

Everything was working fine until morning i found a strange issue of unexpected token <

I dint changed any code

scripts.jade

script(type="text/javascript",src="/vendor/jquery/dist/jquery.js")
script(type="text/javascript",src="/vendor/angular/angular.js")
script(type="text/javascript",src="/vendor/angular-resource/angular-resource.js")
script(type="text/javascript",src="/vendor/angular-route/angular-route.js")
script(type="text/javascript",src="/app/app.js")
script(type="text/javascript",src="/app/main/mvMainCtrl.js")
script(type="text/javascript",src="/app/account/myNavBarLoginCtrl.js")

server.js

/**
 * Created by nyaconcepts on 4/10/2014.
 */
var express=require('express'),
    stylus=require('stylus'),
    bodyParser = require('body-parser'),
    morgan  = require('morgan'),
    mongoose = require('mongoose');

var env=process.env.NODE_ENV=process.env.NODE_ENV||'development';

var app=express();

function compile(str,path){
    return stylus(str).set('filename',path);
}
//Supported by older version
/*app.configure(function(){
    app.set('views',__dirname+'/server/views');
    app.set('view_engine','jade');
});*/

if ('development' == env) {
    app.set('views',__dirname+'/server/views');
    app.set('view engine','jade');
    app.use(morgan('dev'));
    app.use(bodyParser());
    app.use(stylus.middleware({
         src:__dirname+'/public',
         compile:compile
        }
    ));
    app.use(express.static(__dirname+'../public'));
  }

if(env=='development'){
    mongoose.connect('mongodb://localhost/multivision');
}
else {
    mongoose.connect('mongodb://kamlesh:multivision@ds053658.mongolab.com:53658/multivision');
}
var db=mongoose.connection;
db.on('error',console.error.bind(console,'Connection Error..!!'));
db.once('open',function callback(){
    console.log('multivision db opened');
});

/* For displaying partial message
var messageSchema = mongoose.Schema({message: String});
var Message = mongoose.model('Message', messageSchema);
var mongoMessage;
Message.findOne().exec(function(err, messageDoc) {
    mongoMessage = messageDoc.message;
});*/

app.get('/partials/*', function(req, res) {
    res.render('/../../public/app/' + req.params);
});

app.get('*',function(req,res){
    res.render('index');
        //mongoMessage : mongoMessage
});

var port=process.env.PORT||3030;
app.listen(port);

console.log('Listening on port'+port+'---');

Please suggest some solution


回答1:


If I had to guess, I'd bet your routes aren't setup properly and you're loading HTML in all those JS files.

In dev tools, click the right side of one of those syntax errors.

If jquery.js doesn't come up, you need to figure out why. Once you get the correct assets loading, that should solve the problem.



来源:https://stackoverflow.com/questions/23166069/unexpected-token-while-running-mean-stack-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!