Just because you need the file on the client side doesn't mean it has to be stored on the server side as well.
Create a route for the desired file and have the handler return the dynamically generated script.
router.get("/public/js/notafile.js", function(req, res) {
// This can be more than one line
res.send("function(){console.log('yey')}");
});
You can utilize a template, such as an underscore template or another type of file that replaces placeholders to create complex functions dynamically.
If you are serving a file that the client expects to be in your /public directory, ensure this is bound before your static binding. For example, place it before:
app.use(express.static(__dirname + '/public'));