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 }); 
     } 
    }); 
}); 

Got Fehler sein:AssertionError: Pfad muss eine Zeichenfolge

 
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) 

Antwort

3

den Fehler Lesen:

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) 

Schauen Sie sich Ihr Code:

require([ 

Ein Array ist nicht ein Faden.


Ich glaube, ich gearbeitet, was los ist, obwohl es viel einfacher gewesen wäre, wenn jemand über spezifischere gewesen war, wo sie sind kopier Einfügen von Code aus. Die Funktion require(array, callback) ist Teil von RequireJS. NodeJS verwendet das nicht und hat stattdessen require(string). Wenn Sie RequireJS in NodeJS verwenden möchten, müssen Sie zunächst requirejs installieren und anfordern.

+1

Dieses Ökosystem ist selbstzerstörerisch. Es ist erfundene Komplexität. – grantwparks

Verwandte Themen