Many machines come pre-installed with NodeJS, or might have been installed previously, or as a dependency. So before we do anything, we should check if it's already installed:
- Open up a terminal (
If node is pre-installed
Browse to the NodeJS website. It will display two versions (if
it detects your OS. Otherwise select your OS first). If your
node -v version
matches one of these, you're good. If it doesn't, we recommend that you use
Node LTS. If you're worried upgrading might break something on your system, you
can continue as if everything is fine; we won't be able to provide support when
something unexpected happens.
If node is not installed
There are a couple of ways to install NodeJS:
Both options support Windows, MacOS, and Linux. If you don't know what to do, using an installer is the easier.
- We recommend using the LTS version. This is also indicated as recommended on the NodeJS website "for most users".
- Follow the instructions on the webpage and/or during the installer and install NodeJS.
Testing the installation
After the installer is done, or the package manager has completed, or the binary has been copied and the instructions have been followed, it's good to test if everything is alright.
- Open up a terminal (
The version should match the one on the website.
Note: It is important you open a new terminal window. Any open terminal windows might not have been refreshed after the installation completed. This means that the open terminals don't know that a new program was installed.
'node' is not recognised
If you've used the official installer, your
PATHshould have been automatically configured, but if your shell has trouble locating your globally installed modules — or if you build Node.js from source — update your
PATHto include the
On MacOS and Linux you may accomplish this by adding the following to either
$ export PATH=/usr/local/share/npm/bin:$PATH
On Windows open the start menu and search for "environment variables". You'll need to edit the
PATHentry and add the path to the
npmbinaries here. Usually these are found at
C:\Program Files\nodejs. If you browse here with your
File Explorer, you should find
Close any open terminals and open a new one.
Please follow these instructions to download exercism cli for your OS.
Once CLI is all setup & configured, download the first exercise -
Each assignment then needs some tools to run the tests. They can be installed running this command within each assignment directory:
$ npm install
But what is npm and why does this work?
This works because
npmis a package manager that comes bundled with
NodeJS, which has been installed per the steps above. The
npmcommand looks for a
package.jsonfile, which is present in each assignment folder. This file lists the
"dependencies"above, which are then downloaded by
npmand placed into the
The scripts in the
package.jsonuse the binaries from the local
node_modulesfolder, and its these scripts that are used to run the tests, as listed in the