Question

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

enter image description here 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

Was it helpful?

Solution

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. enter image description here

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top