Error in VS Code, but not in my Index.html

I am new to the JavaScript journey as I was learning about JSON; nevertheless, this inquiry is about JavaScript so let me get to the issue.

When I put the below code into VS Code and try to run this through the Terminal it produces an error (see attached). However, if I call this apps2.js file from my .html file it will produce the results of ‘it was true’.

Therefore, I’m just asking the basic question of:

  1. Can the apps2.js file be ran inside the VS Code Terminal to display the results, or does this always need to be called and ran through the .html file?

The location of this file is: C:\VS Code\javascript
and the file name is apps2.js

if you has installed nodejs in your computer:

node  app2.js