Thursday 20 April 2017

__dirname is not working in node js with webpack bundling

My current directory is

D:\bkp\Programming\TestWorks\nodejs\testApp

but when i am using __dirname and trying to show a file with express server it gives me this error

Error: ENOENT: no such file or directory, stat 'D:\views\index.html'

my code for that is

res.sendFile(__dirname + 'views/index.html');

when i am bundling it with webpack and run the bundle file then this happens. Otherwise if i just run the normal app.js file it works fine. Help would be appreciated.



via ShocKwav3_

No comments:

Post a Comment