This topic contains 4 replies, has 3 voices, and was last updated by Sean Sean 1 year, 5 months ago.

Angular Theme with Express.js + Node.js doesn't work


  • yacafx
    Participant

    Posts: 1
    Member Reply #7652

    Hi,

    I try to use te theme and as standalone works fine, but when I try to use ir with a Express/node server Angular doesent load correctly 🙁 The errors that i receive is

    Uncaught SyntaxError: Unexpected token <

    I attach a couple of screenshoots.

     

    ¿Can you help me please?

    Error 1


    yacafx
    Participant

    Posts: 1
    Member Reply #7653

    I solve it! =D

    I need to specify the folder with my js files for Express can serve static files:

    app.use(express.static(__dirname + ‘/public’));

    app.use(express.static(__dirname + ‘/public/app’));

     

    I found that info on http://expressjs.com/en/starter/static-files.html

    Sean
    Sean
    Keymaster

    Posts: 4526
    Support Staff Reply #7658

    Great! Well done. Thanks for sharing this solution. Good luck with your project 🙂


    chrispalmezan
    Participant

    Posts: 4
    Member Reply #9291

    Hi. I could not get it.

    I’m trying to set a MEAN app, but when I try to set the express on main.js (on js folder) it doen’t work.

    like that:

    /***

    // Metronic AngularJS App Main Script

    ***/

    var express = request(‘express’);

     

    var app = express();

     

     

    app.use(‘/’, express.static(‘deepfreeze/views’));

     

    /* Metronic App */

    var DeepFreezeApp = angular.module(“DeepFreezeApp”, [

    “ui.router”,

    “ui.bootstrap”,

    “oc.lazyLoad”,

    “ngSanitize”

    ]);

     

    I’m also trying to serve the app on port 3000, instead of 8080.

    But when I set an app.js file calling it, all the js and css files could not be found. I receive a console log as 404 status.

    How can I serve the Angular version with Express????? Please, anyone can help me?????

    Thanks!!!

    • This reply was modified 1 year, 5 months ago by  chrispalmezan.
    Sean
    Sean
    Keymaster

    Posts: 4526
    Support Staff Reply #9302

    Hi,

    First you should check the issue outside the theme and make sure the port you are accessing is working.
    Metronic including gulp task to launch a localhost using https://www.npmjs.com/package/gulp-connect.
    You can check(if haven’t yet) the documentation “_documentation/index.html” and try to launch the gulp localhost server.

    If you need any further help please let us know.

    Thanks.

You must be logged in to reply to this topic.