node.js - Webpack/Gulp/Express error: No such file or directory -


i have project consists of file upload form, uses express router , jade/pug template rendering 2 different views.

i'm attempting use webpack compile javascript files 1 (backend.js), , gulp compile backend.js file, along 3 .pug files, directory.

after webpack compiles js files contained in project, places them in build/backend.js: project-after-webpack

and finally, gulp takes backend.js file, along pug templates located in folder in project, , places them in structure, compiling backend.js main.js, , turning pug files html files: project-after-gulp

the rest of project in root directory.

one of javascript files responsible rendering views upon http requests. i'm having trouble. without gulp , webpack, i'm able render .pug views no problem using res.render(). however, i'm getting "no such file or directory" error when use gulp , webpack. how i'm attempting render form.pug file, gulp turned form.html.

router.get('/', function list (req, res, next) { //res.render('submissions/form.pug' res.sendfile(path.join(__dirname+'build/submissions/form.html'), { submission: {}, action: 'add' }); });

and console telling me enoent: no such file or directory, stat '/form.html', though can see there in fact file there.

i'm not sure if path incorrect, if using .sendfile function requires i'm missing, or if plain impossible. wuold appreciated.

i think point of using path.join() (see docs here) build path string compatible operating systems.

it takes path fragments arguments so:

    router.get('/', function list (req, res, next) {         //res.render('submissions/form.pug'         res.sendfile(path.join(__dirname, 'build', 'submissions', 'form.html'), {             submission: {},             action: 'add'         });     }); 

maybe / missing between __dirname , build otherwise?


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -