0

This is the Linux bash terminal:

$ node 
> 'aBc'.toLowerCase()
'abc'
> .exit
$ echo "console.log('aBc'.toLowerCase()) " | node
abc
$ echo "'aBc'.toLowerCase()" | node

You can see when I type in Node REPL 'aBc'.toLowerCase() I get the output. But when I execute echo "'aBc'.toLowerCase()" | node I don't get any output. Why?

There is a way to get the output without console.log? Maybe is it goes to other ouptput stream?

1 Answer 1

0

Found an solution on Reddit by sn-x user 09f911029d7 users.

node no showing normal statments output when non running in interactive mode. To see the output there are 2 options:

node -i "5+5"

This will force node to run as in interactive mode, and will show the output.

The other way is to use:

node -p "5+5"

This will tell node to print the executed last value of the statment. (same result as before).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .