Skip to content Skip to sidebar Skip to footer

Executing Node.js File In A Bash Script

I was looking at this example here: https://bbs.archlinux.org/viewtopic.php?id=168479 It says I can execute JS/Node.js this way: #!/bin/sh exec node --harmony <

Solution 1:

As mentioned in the comment to your question, it is a heredoc. It selects all text from <<EOF to the first instance of EOF. You can use other marker names, not just EOF.

It allows you to define a block of text including newlines.

The syntax has the equivalent effect of

echo'console.log("hello")' | exec node --harmony

in that it pipes the content of the heredoc to node. But you can include newlines which is nice.

Post a Comment for "Executing Node.js File In A Bash Script"