JavaScript is an amazing language that runs in both the browser and the server. Wondering what you can do with JavaScript? With JS you can:
- Build websites and user interfaces
- Create webservers
- Write scripts
- Fetch data from databases using an ORM
- And a lot more!
In order to run JavaScript on your computer, you'll want to install NodeJS which is a runtime environment for JavaScript. This will allow you to run JavaScript files outside of the browser.
Option 1 - Install with Homebrew
Homebrew is a package manager for macOS and Linux that can be installed through the command line. If you are wondering how to use the command line, check out this guide on mac's terminal.
Once you've opened your terminal, paste in the following and hit enter.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After homebrew is finished installing, run the following command to verify that the installation was successful.
brew -v
If successful you should see the version of homebrew outputted in your terminal, similar to the below. Note that your version may have a different version number and that's fine!
Homebrew 3.1.11
Once homebrew is installed you can install NodeJS by using the following command.
brew install node
Now you should be able to run the following command and see the following output. Again the version number isn't super important here although you'll want to verify you are using the right version before you begin working on anything important.
node -v
v20.14.0
Option 2 - Download directly
If you don't want to install Homebrew, you can download JavaScript directly from the source, nodejs.org. Just click on the Download Node.js (LTS) button and run the installer. Once done the node -v
command should show you the version that you just installed.
Congrats, you just installed JavaScript on your computer!