1

I am brand new, have recently learned HTML and CSS. After starting JavaScript i tried to run this and check it in console log.

// variables

// numeric
var x = 1

x = 24

console.log(x)

I am using VSCode and installed Code Runner. I right clicked to run code and receive this error msg.

[Running] node "/Users/C/Desktop/Project 02/src/index.js"
/bin/sh: node: command not found

[Done] exited with code=127 in 0.021 seconds 

Not sure what to do and I basically started trying to learn Javascript today.

I am using a MacOS - Catalina if that helps.

Thank you for any input and I apologize if this has been asked before, since I just joined Stackoverflow today.

Edit: Thank you for all the help. I needed to download Node.js that fixed the issue.

Sieto
  • 19
  • 3
  • 5
    You need to install the node.js runtime. https://nodejs.org/en/ – Matt U Aug 09 '21 at 03:54
  • Please refer this thread for answer https://stackoverflow.com/questions/13593902/node-command-not-found – Tony Tin Nguyen Aug 09 '21 at 03:58
  • 1
    JS is a dynamically typed language, so you don't need to use a syntax for declaring types, only the scope, using the three mentioned variable types in this answer. – JΛYDΞV Aug 09 '21 at 05:07

2 Answers2

1

You need to install NodeJS on your Mac

nodejs download page

1

Although the syntax is correct, I would recommend defining a variable by the following

There are 3 ways to define a variable:

  • let
  • var
  • const

For your example, we will use let, the modified syntax is given below:

let x = 24
console.log(x);

Secondly, you need nodejs, download it from here and run node .

doge
  • 33
  • 5