I want to reqiure my html but I can not do it. My code is so simple :
module.exports = {
html: require('./template.html')
};
When I run codes, It gives this error:
SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
require (module.js:385:17)
at Object.<anonymous> (D:\frontend\lokidump\server\views\traders\betofcourse\upcomingEvents\index.js:2:9)
When you use require
on a file it is expecting a JavaScript file, not an HTML file. If you want to load the contents of the HTML file into a variable look into fs.readFile