/bin/sh: node: command not found - in VScode, running Javascript

Viewed 6108

Im trying to run this simple code in VSCode for learning Javascript but I keep getting this error:

[Running] node "/var/folders/xr/30nkhmxs7159fblbjtfj2jhw0000gn/T/tempCodeRunnerFile.javascript" /bin/sh: node: command not found

[Done] exited with code=127 in 0.014 seconds

I've looked online and have tried changing the CodeRunner Executable Map as I saw in another post but it doesn't seem to be helping.

Thanks!

let admin, name; // can declare two variables at once

name = "John";

admin = name;

alert( admin ); // "John"

1 Answers

First of all, check the output of which node in the default terminal application. If the output is empty, this means that the path where the node binary resides is not in your $PATH. Try to find the location of the node executable. After this, check what's the shell you're using by running echo $SHELL. If it returns something like /bin/bash, create a file(may already exist) named ".bash_profile" or ".bashrc" and there, add the following: export PATH=$PATH:<location of node>, replacing <location of node> with the actual location of the node binary.

Related