Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you pipe scripts into NodeJs from command line?

From command line, I'd like to take a script from my paste board (FYI: pbpaste is an OSX feature) and pipe it into the Node's repl command line tool. For example:

pbpaste | node -e

This does not evaluate the contents in my clipboard. How do I get the runtime to do this?

like image 853
thesmart Avatar asked Jan 16 '13 06:01

thesmart


1 Answers

The -e option is for running JS passed as an argument. To run JS from stdin, you can simply pipe to node directly.

pbpaste | node
like image 173
loganfsmyth Avatar answered Nov 08 '22 04:11

loganfsmyth