Exercism CLI Setup & Install JavaScript locally: Possible Errors on a Mac
Cindy Lam
Posted on December 14, 2021
When working on Exercism exercises, you can either solve the problems using the online editor or working on them locally in your own favorite IDE and submit them through the CLI (Command Line Interface) on terminal. While installing Exercism locally on my MacOS, I have encountered several errors that took me some times to figure them out.
You may not have encountered the following errors if you have not already had Homebrew or Node installed.
As found, here are the causes of the errors I encountered:
- Outdated Homebrew Version
- Outdated Node Version
I am going to generally walk through my debugging process - how I found the issue and how I researched to figure it out.
If you are comfortable installing exercism via Homebrew, Exercism will give you the following 2 steps:
Step 1: Install Exercism through Homebrew
brew update
brew install exercism
exercism version --> this is only used for checking the exercism version
Step 2: Configuring the CLI in the terminal
exercism configure --token=[THIS IS THE SECRET TOKEN THAT CANNOT BE SHARED]
Once this is completed, you have successfully installed Exercism locally.
Outdated Homebrew Version
Initially, I got an error when running brew update
:
Error:
homebrew-core is a shallow clone.
I did not know what is going on until I checked the Homebrew version using brew --version
, then I found the following error:
unknown or unsupported macOS version: :dunno (MacOSVersionError)
I did some google searches and found this stack overflow question regarding Homebrew failed on a macOS version. As noted in one of the highest votes answer, here is how to update the Homebrew version:
brew update-reset
It would take some times to reset. Once it is reset, you can check the version again using brew --version
. You should see the current version of the Homebrew this time instead of an error log.
Outdated Node Version
However, even though I have reset/updated the Homebrew version, when I ran brew update
again, I still saw the same error:
Error:
homebrew-core is a shallow clone.
I did not know why. I decided to install exercism and configure first and ignore the error. Until when I did npm install
, I got a lot of warnings on different npm packages outdated or deprecated. I also got an error when running npm test
:
SyntaxError: Unexpected token
After several trials and errors to see if I could do an npm install for each older npm packages, I realized this was a time consuming and ineffective method. It did not really help me to know the actual cause of the issue.
I decided to ask my friend, Google, and I found this stack overflow question. One of the answer actually tell me the possible cause of the issue could be an outdated Node version.
Using node --version
to find out the current version I was on.
Then, using nvm install [NEW NODE VERSION]
to install the latest version.
(the version I have in the code snippet below is only the latest one at the moment I am writing this post, in order to check the most recent Node version, click here)
nvm install 16.13.1
Once these steps are completed, congrats!! You should be able to successfully do npm install
and npm test
this time without any more errors!!
Thank you for reading through this and hopefully it can help you out if you are encountering similar issues I did.
Below are some additional resources just in case you might find them helpful:
- What is Homebrew and How to install
- How to update Node.js
- How to install JavaScript locally for Exercism exercises
Have fun, Exercism-ing Locally!
By the way, if you ever see the following error when doing npm test
, it is possibly because you have not npm install
all the packages for the exercise.
> test
> jest ./*
sh: jest: command not found
Posted on December 14, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
December 14, 2021