Why does the terminal throw out "command not found: $"

Hello community,

I’m struggling with a small issue while learning the section “Going off-platform with JavaScript”.
As it is mentioned in the task, I did the following:

  1. I created a file (via Visual Studio Code) with the name “my-app.js” and the following code (which I just copied and pasted from CC):
    // my-app.js
    console.log(process.env.PWD);
  2. I checked if Node is already installed. It is.
  3. I gave the following command (also copy and paste) into the terminal:
    $ node my-app.js
    /path/to/working/directory

The Problem is, that the terminal responds:
zsh: command not found: $
zsh: no such file or directory: /path/to/working/directory

As I did the least on my own, I can’t understand, why it’s not working. Does anyone has a clue?
Thanks in advance!!

Greetings, Johanna

1 Like

Hello @tantehannsen ,

What happens when you try just node my-app.js ? Also, i’m assuming that you’re running this command in the same directory as my-app.js.

Michael

Hello @mdwiltfong ,

thanks for your rapid answer!

I now found out my mistake… You was absolutely right. I did insert the whole phrase “$ node my-app.js
/path/to/working/directory”, because I did not know, how to read it properly (that only the “node my-app.js” is the command). I also was not aware of the need to tell the terminal the right directory. (As I got used to follow stupidly every step at codecademy, and there was no hint, I just forgot to rummage about the things I learned so far at using a console). And the other thing is, I was never ever shown how to read such a documentary. Oh man! Thanks to you and my friend, who is a programmer already, too :slight_smile:

Thanks and nice greetings
Johanna

1 Like

/path/to/working/directory”, because I did not know, how to read it properly (that only the “node my-app.js” is the command). I also was not aware of the need to tell the terminal the right directory. (As I got used to follow stupidly every step at codecademy, and there was no hint, I just forgot to rummage about the things I learned so far at using a console). And the other thing is, I was never ever shown how to read such a documentary. Oh man! Thanks to you and my friend, who is a programmer already, too :slight_smile: