2016-12-08 3 views
0
require([ 
    'common', 

    // Libs 
    'jquery', 
    'parse', 
    'i18n', 

    // Modules 
    'modules/login/controllers/login', 
    'modules/page/controllers/page', 

    // Styles 
    'css!../assets/css/bootstrap.min.css', 
    'css!../assets/css/tablesorter-bootstrap-theme.css', 
    'css!../assets/css/common.css', 
], 

function(common, $, Parse, i18n, Login, Page) { 

    // Defining the application router, you can attach sub routers here. 
    var Router = Parse.Router.extend({ 
     routes : { 
      '' : 'index' 
     }, 

     index : function() { 
      var currentUser = Parse.User.current(), 
       view, container; 

      // Load either login screen or navigation bar, 
      // depending on the login state of current user. 
      if(currentUser){ 
       view = new Page.Views.Navbar(); 
       container = '#navbar'; 
      } else { 
       view = new Login.Views.Login(); 
       container = '#main'; 
       $('#navbar').html(null); // Remove the navbar 
      } 
      view.render(function(el) { 
       $(container).html(el); 
      }); 
     } 
    }); 

    $(function() { 
     // Initialize internationalization 
     i18n.init({ 
      saveMissing: true, 
      debug: true, 
      //preload: ['dk', 'en'], 
      getAsync: false 
     }); 

     Parse.initialize('****','****'); 

     // Initialize the Router 
     var router = new Router(); 
     Parse.history.start({ pushState: false }); 
    }); 


    $(document).on('click', 'a:not([data-bypass])', function(evt) { 
     // Get the anchor href and protcol 
     var href = $(this).attr('href'); 
     var protocol = this.protocol + '//'; 

     if (href && href.slice(0, protocol.length) !== protocol && href.indexOf('javascript:') !== 0) { 
      evt.preventDefault(); 
      Parse.history.navigate(href, { trigger: true }); 
     } 
    }); 
}); 

получил ошибку:AssertionError: путь должен быть строкой

 
assert.js:85 
    throw new assert.AssertionError({ 
^
AssertionError: path must be a string 
    at Module.require (module.js:482:3) 
    at require (internal/module.js:20:19) 
    at Object. (/home/historiejagt.portaplay.dk/public_html/app/app.js:4:1) 
    at Module._compile (module.js:556:32) 
    at Object.Module._extensions..js (module.js:565:10) 
    at Module.load (module.js:473:32) 
    at tryModuleLoad (module.js:432:12) 
    at Function.Module._load (module.js:424:3) 
    at Module.runMain (module.js:590:10) 
    at run (bootstrap_node.js:394:7) 

ответ

3

Читать ошибку:

AssertionError: path must be a string 
    at Module.require (module.js:482:3) 
    at require (internal/module.js:20:19) 
    at Object. (/home/historiejagt.portaplay.dk/public_html/app/app.js:4:1) 

Посмотрите на свой код:

require([ 

Массив не строка.


Я думаю, что я работал, что происходит, хотя это было бы намного проще, если бы кто-то был более конкретно о том, где они копирования вставки кода с.

Функция require(array, callback) является частью RequireJS. NodeJS не использует это и вместо этого имеет require(string). Если вы хотите использовать RequireJS в NodeJS, вам нужно сначала установить и потребовать requirejs.

+1

Эта экосистема является самопровозглашенной. Это надуманная сложность. – grantwparks

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