module "require" inside a Jade file

node.js, pug

Solution

Two problems You should send the function to the Jade file as an argument rather than trying to require it in Jade ie.

var js = require('fs');
res.render('myjadefile', {fsFunction: fs});

myjadefile.jade

- var downloadfile = fsFunction.readdirSync('download');
for f in downloadfiles
   // rest of your code

Also, in line 2 you are calling function "readdirSync" without defining it anywhere. It should be

fs.readdirSync

Problem

I need to use "fs" module inside a Jade file. No other JS file. When I try: ``` - var js = require('fs') - var downloadfiles = readdirSync("download") for f in downloadfiles url loc= D + "/download" + f lastmod= buildDate changefreq daily priority 1.0 ``` I got the error "undefined is not a function"

Original source

Related problems