• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Execute Javascript using Node in terminal

Resolved: Execute Javascript using Node in terminal

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I know that

Node.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:
but I get zsh: unknown file attribute. The same happens with node console.log('hello').
If I instead create a file hello.js and put the console inside it and then I run:
it works. Why? What am I missing?
Sorry for the (maybe) stupid question

Answer:

It’s because the console.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!

javascript node.js
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Resolved: Azuer Service Bus SDK not receiving the specified messages

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.