DEV Community

Cover image for Exercism CLI Setup & Install JavaScript locally: Possible Errors on a Mac
Cindy Lam
Cindy Lam

Posted on • Edited on

Exercism CLI Setup & Install JavaScript locally: Possible Errors on a Mac

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:

  1. Outdated Homebrew Version
  2. 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
Enter fullscreen mode Exit fullscreen mode

Step 2: Configuring the CLI in the terminal

exercism configure --token=[THIS IS THE SECRET TOKEN THAT CANNOT BE SHARED]
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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:

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
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
ngl4 profile image
Cindy Lam

This is my third time using this!

Collapse
 
ngl4 profile image
Cindy Lam

This is my second time using this article to solve same issue on Jan 9th, 2022.

Collapse
 
ngl4 profile image
Cindy Lam

Thanks to this article, I am able to resolve similar issues on Dec 27th, 2021.