Welcome to the wonderful world of JavaScript development! I hope you find it enjoyable and rewarding.
The basic tools of the JS trade these days are:
node
, which runs JavaScript code.nvm
(Node Version Manager), which updatesnode
and lets you switch between different versions.yarn
, a package manager for installing projects' dependencies.
Once you have these tools on your system, you will be able to download and run most JS projects, as well as create your own!
See NVM on GitHub.
TL;DR you'll run a command like this:
# It's HIGHLY RECOMMENDED to copy the install command from
# https://github.com/nvm-sh/nvm instead of using this one.
# Depending on when you are reading this, the NVM version
# given here may be out of date.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Then you'll need to close and reopen your terminal to make the nvm
command available in your shell.
If command -v nvm
prints nvm
, you should be good to go.
Once you have nvm
, installing the latest version of node
is just:
nvm install node
See nodejs.org for more info about node
.
node
comes with its own package manager, npm
, but many projects these days use an alternative, yarn
.
If you installed a recent version of node
, setting up yarn
is as easy as running:
corepack enable
This will create a yarn
executable in ~/.nvm/versions/node/v23.8.0/bin
(assuming you installed node
version 23.8.0).
If which yarn
outputs a path in that directory, it worked!
Note: the yarn
executable created by corepack
is actually just the installer for yarn
.
The first time you run a yarn
command, you will be prompted with a message like:
! Corepack is about to download https://registry.yarnpkg.com/yarn/-/yarn-1.22.22.tgz
? Do you want to continue? [Y/n]
You can just hit enter
to install yarn
and continue.