2015-01-13 2 views
-1

Это, вероятно, ошибка начинающего. Я получаю эту ошибку "неперехваченным SyntaxError: Неожиданные лексем <" require.js: 1requirejs не загружается должным образом

I установки основной сервер экспресс-то я загрузить мой 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 (требуется конфигурация)

/*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 ((«TEST !!»); не появляется при загрузке моей страницы.

Ошибка все еще появляется, когда я комментирую весь файл main.js!

ответ

0

Extreme noob error, мой экспресс-корневой каталог не был настроен правильно!

Смежные вопросы