I wonder how to executue JS inside a HTML doc on the server

In php you use <?php ?> to execute php code inside an html doc. How do you do that in Nodejs

You should use template engine. See ejs, or jade for example.

http://embeddedjs.com/

http://jade-lang.com/

If you are using Express nodejs framework, then it is very comfortable to use jade. There is also template engine called Bliss which is like Razor Engine in ASP.NET

if template engine is ejs then <%- nameofvariable %>

you can use the template jade useing express framework for nodejs. https://github.com/visionmedia/jade#readme