I have been trying to create a simple html file in the public folder of my Express.js app, but can't get the path right. Can anybody help me out?
Here is the part of my app.js where I configure my static folder:
app.use(express.static(path.join(__dirname, 'public')));
and here's the code I'm using to try to create the index.html file in the public folder:
exports.index = function(req, res){
var fs = require('fs');
fs.openSync(__dirname + /public/static_html/index.html, 'w')
};
However, node.js throw an error:
500 Error: ENOENT, no such file or directory
'C:nodejsnode_modules.binmyapproutespublicstatic_htmlindex.html'
Why is it pointing to the to the public folder inside routes?
I would like the path to be:
'C:nodejsnode_modules.binmyapppublicstatic_htmlindex.html'
Can anybody help please?