Angular网站正在加载空白页

时间:2016-06-17 08:01:05

标签: angularjs node.js express

我有一个Angular 1.x网站。当我尝试加载任何页面时,我只得到一个空白页面。如果我查看空白页面的来源,我可以看到正确的index.html代码。

但是,如果我点击index.html源代码中的(例如)angular.js链接,它只会加载index.html页面。它不会加载正确的angular.js文件。

当我尝试加载其中一个页面时,我在浏览器的控制台中看到以下错误:

angular.js:1 Uncaught SyntaxError: Unexpected token <
ui-bootstrap-tpls.js:1 Uncaught SyntaxError: Unexpected token <
jquery.js:1 Uncaught SyntaxError: Unexpected token <
bootstrap.js:1 Uncaught SyntaxError: Unexpected token <
bootstrap-switch.js:1 Uncaught SyntaxError: Unexpected token <
angular-bootstrap-switch.js:1 Uncaught SyntaxError: Unexpected token <
angular-cookies.js:1 Uncaught SyntaxError: Unexpected token <
angular-mocks.js:1 Uncaught SyntaxError: Unexpected token <
d3.js:1 Uncaught SyntaxError: Unexpected token <
nv.d3.js:1 Uncaught SyntaxError: Unexpected token <
angular-nvd3.min.js:1 Uncaught SyntaxError: Unexpected token <
angular-resource.js:1 Uncaught SyntaxError: Unexpected token <
angular-sanitize.js:1 Uncaught SyntaxError: Unexpected token <
angular-scenario.js:1 Uncaught SyntaxError: Unexpected token <
angular-translate.js:1 Uncaught SyntaxError: Unexpected token <
angular-ui-router.js:1 Uncaught SyntaxError: Unexpected token <
angular-ui-switch.js:1 Uncaught SyntaxError: Unexpected token <
async.js:1 Uncaught SyntaxError: Unexpected token <
lodash.js:1 Uncaught SyntaxError: Unexpected token <
ngStorage.js:1 Uncaught SyntaxError: Unexpected token <

在尝试加载我的应用时出现此错误:

app.js:3 Uncaught ReferenceError: angular is not defined

你们有谁知道什么会导致这种错误?在开始我的应用程序之前,我可以看到bower正确地获取了所有这些文件,因此我对导致此问题的原因感到困惑。

这是一个Node / Express / Angular应用程序。谢谢!

编辑:感谢大家的评论。奇怪的是,如果我将我的主节点应用程序(与路由)与之前的工作版本进行比较,它们就完全相同了。这是主要的快递代码:

var express = require('express');
var app = express();
var server = require('http').Server(app);

/**
 * Setup routers
 */
var oneRoute = require('./one/index.js');
var twoRoute = require('./two/index.js');
var indexRoute = require('./index/index.js');

// set express options
app.set('env', process.env.NODE_ENV);
app.set('x-powered-by', false);
app.set('views', [
    path.join(__dirname,
    'lib/views')
]);


app.set('view engine', 'jade');
app.use(bodyParser.json({type: 'application/json', limit:'50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true }));

app.use(express.static(__dirname + '/assets/client'));
app.use('/testPublic', express.static(__dirname + '/testPublic'));

app.use('/one', oneRoute);
app.use('/two', twoRoute);
app.use('/', indexRoute);

app.use(function(req, res, next) {
    if (req.path.indexOf('assets/admin') > -1 ||
        req.path.indexOf('assets/jquery') > -1 ||
        req.path.indexOf('assets/bootstrap') > -1 ) {
        next();
    } else {
        res.sendFile('./client/index.html', {root: __dirname});
    }
});

// Assets
app.use(require("connect-assets")({
    paths: ["assets"],
    helperContext: app.locals
}));

0 个答案:

没有答案
相关问题