You can install NodeJs for running JavaScript directly using the node command. NodeJs is an asynchronous event-driven JavaScript runtime, which is designed to build scalable network applications. Here we will just use it from running JavaScript.
sudo apt update
sudo apt install nodejs
Check Version:
nodejs -v
node -v
brew install node
Check Version:
node -v