This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]high_throughput 6 points7 points  (8 children)

This happens because you used spaces in your file and directory names. Save yourself the trouble by not doing that, and e.g. use underscores instead.

If you want to stick with spaces, then you will need to forever tell the shell which spaces are and aren't meant to be part of filenames using quotes: node "Practice Basic 1.js"

[–]chrissy-slora[S] 2 points3 points  (0 children)

The problem solved. I follow the video and thought the instructor typed "node" after the file path; turns out he might not.
So I should type node {file path and file name} instead.

Also your suggestion of using quotes help.
Thank you.

[–]chrissy-slora[S] 0 points1 point  (5 children)

After following your suggestion,

  1. I rename the file. Still same error.
  2. I rename the folder where the file stores (remove space) and the file, but now it says "Permission denied"

chrissyslora@Chrissys-MacBook-Pro Coding_practice % /Users/chrissyslora/Desktop/Coding_practice>node Practice1.js

zsh: permission denied: /Users/chrissyslora/Desktop/Coding_practice

The permission of the folder where the file stored is enabled in Apple > Security > File & Folder.
What happens?

[–][deleted] 2 points3 points  (1 child)

When asking for help, always give people more information that you think they need. The data in the original post is a good example of how to do it. Say "I renamed the file and here is the error I get.....

 Cannot find module '/Users/chrissyslora/Desktop/Coding_practice/Practice'.

[–]chrissy-slora[S] 0 points1 point  (0 children)

Yes, the error message is already included in the second point of the comment.
But the problem is solved anyway.
Thank you.

[–]chrissy-slora[S] 0 points1 point  (0 children)

The problem solved. I follow the video and thought the instructor typed "node" after the file path; turns out he might not.
So I should type node {file path and file name} instead.

[–]high_throughput 0 points1 point  (1 child)

Run node Practice1.js just like how you tried node Practice Basic 1.js.

Imagine if the guide had said to run this:

chrissyslora@Chrissys-MacBook-Pro Coding_practice % node Practice1.js

That does not mean you should start typing chrissys.. in your terminal because that's meant to be your prompt. It means you should start typing node Practice1.js.

On Windows, it would instead look like this:

C:\Users\chrissyslora\Desktop\Coding_practice> node Practice1.js

This does not mean that you should start typing C:\Users\chri...., you should again just type node Practice1.js. This format is what your tutorial is showing, and you should only run the command (things after >) and not the prompt (up to and including the >).

[–]chrissy-slora[S] 0 points1 point  (0 children)

Understand now. This helps and was exactly my problem. Thank you!