Question:
I know thatNode.js allows to write JavaScript code that runs directly in a computer process itself instead of in a browser
Reading this, I try to open my terminal and run:
node console.log('hello')
.If I instead create a file
hello.js
and put the console inside it and then I run:Sorry for the (maybe) stupid question
Answer:
It’s because theconsole.log('hello')
is being evaluated by your shell (zsh
) before running the command and it has no idea what console.log('hello')
is. You could use the -e
or --eval
arguments.If you have better answer, please add a comment about this, thank you!