requirejs没有正确加载

时间:2015-01-13 18:55:18

标签: express requirejs

这可能是一个初学者的错误。我收到这个错误 "未捕获的SyntaxError:意外的令牌<" require.js:1

我设置了一个基本的快速服务器然后加载我的index.html:

app.use('/' ,function(req,res,next) {
    res.sendfile("index.html", {'root':"../"});
});

的index.html

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title> blabvla </title>
    </head>
    <body>
        <h1> BLABLALBLAL </h1>  
        <section id="app">

        </section>

        <footer> </footer>
        <script  data-main="application/main" src="bower_components/requirejs/require.js"></script>
    </body>
</html>

Main.js(require config)

/*global require*/
'use strict';

// Require.js allows us to configure shortcut alias
require.config({
    // The shim config allows us to configure dependencies for
    // scripts that do not call define() to register a module
    shim: {
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: [
                'underscore',
                'jquery'
            ],
            exports: 'Backbone'
        }
    },
    paths: {
        jquery: '../bower_components/jquery/dist/jquery',
        underscore: '../bower_components/underscore/underscore',
        backbone: '../bower_components/backbone/backbone',
        text: '../bower_components/requirejs-text/text'
    }
});

require([
    'backbone',
    'views/app',
    'routers/router'
], function (Backbone, AppView, Router) {
    /*jshint nonew:false*/
    // Initialize routing and start Backbone.history()
    new Router();
    Backbone.history.start();
    console.log("TEST !!!");
    // Initialize the application view
    var appview = new AppView();
    appview.render();
});

Console.log((&#34; TEST !!&#34;);在我加载页面时没有显示。

当我评论整个main.js文件时,错误仍会出现!

1 个答案:

答案 0 :(得分:0)

极端的noob错误,我的快速根目录没有很好地配置!