Express js render pug|ejs file throws Jquery error

170 views
Skip to first unread message

Gaetano Vallarelli

unread,
Jan 31, 2017, 6:53:45 AM1/31/17
to Express
i'm having an issue with ExpressJs rendering and Jquery.

my app.js (main file) is

   
restapi=require('express')();
   
const pug = require('pug');
    restapi
.use(express.static(__dirname+"/public"));
    restapi
.set('views', __dirname+'/views');
    restapi
.set('view engine','pug');
    restapi
.get("/view/:datalog?",(req, res)=>{
     
var datalog=req.params.datalog;
      res
.render("index",{title:"Hey",rows:"hello"});
             
   
})


my index.pug file (i've been using EJS either) is

   
 html
      head
       title
= title
       script
(src='/js/jquery-3.1.1.min.js')
       script
.
         window
.$ = window.jQuery = module.export;
         $
().ready(function(){console.log("READY")});
         
(alert("HELOOOOOOOOOOOOOOOOO"))
       body
         rows

it throws me an error that can't find jquery module
if i remove the `window.$ = window.jQuery = module.export` (i've tryed even with `= require("jquery"`) instead of module export) the simple javascript shows me the alert.

i've even tryed to link jquery script to the cdn repository. it always gets me error.

i've even tryed moving all the files to the root folder with no public/static assignment.

nothing seems to work...
What am i missing?!
Reply all
Reply to author
Forward
0 new messages