Running the smart mirror on my mac

Getting the smart mirror software to run on my mac.


So now we’ve got an editor installed, we’ve got the code, we’ve got NodeJS.

It’s time to try and start the smart mirror software on my Mac.

But first we have to do something else.  The magic mirror code provided by Michael Teeuw uses a couple of dependencies.  In other words, Michael used some “npm” packages to add additional functionality to the code. (see my post on installing NodeJS for some more info on what “npm” is).  The problem is : knowing which dependencies.

Well, it turns out that every package comes with a .json file.  A .json file (pronounced “jason”) is a text file with structured information.  It stands for “Javascript object notation”.  Kind of like an xml file, but different.  Detailed info can be found here.

The file we’re looking for is called  “package.json”.

Let’s investigate this.  Open a terminal window and navigate to the directory where the smart mirror code is residing.  On my computer that’s

cd /Github/Smartmirrorproject/

it’s important to note that all of this is case sensitive !



this lists the files in the folder.  One of the files should be “package.json”.  I want to see the contents of that file.  In order to do that I could navigate to it in my finder and double click it, but as i’m in a terminal I might as well look it at here.  Just type

cat package.json

the “cat” command shows the entire contents of a file in the terminal.  At the bottom of a file is a section called “dependencies”.  It looks like this :

Schermafbeelding 2017-01-04 om 21.52.43.png

Between the curly braces you see a lists of npm packages, and a version number behind it.  You can see it uses “electron”, “express”, … There is a meaning in the notation of the version numbers.  For more information on this, and also for the rest of the package file, see the npm documentation here.

We could install all of those packages manually, but there’s a much easier way.  While you’re inside the directory of the smartmirrorproject code,  just type

sudo npm install

You will be prompted to enter your administrator password.  Do so, and press enter. Mind that you will not see any characters typing in the terminal as you type your password. This is standard linux behaviour.

What this does is run the npm tool with the “install” command line parameter.  You have to type “sudo” in front of it because you want to install all of this using administrator credentials (to avoid insufficient permissions during the install process).  “Sudo” stands for “super user do”, and executes the entire command that follows as a super user (=administrative user).

What npm will do now, is look at the “package.json” file and detect the dependencies of application.  It will then install all of the correct versions based on the version number, also stored in the “package.json” file.

Now to start the application.  Starting an application is also done using npm. In fact, it also uses the “package.json” file to know how to start the application.  If you look at the contents of the json file again, you will find a “scripts” tag near the top.  One of the entries here is called “start”.  The value is the command that npm has to run in order to start the application.  In this case it’s

Schermafbeelding 2017-01-04 om 22.05.59.png

Notice how it starts the “electron” executable with a javascript file as an argument.  Very easy.  It’s even easier to let npm start the application by using the command

npm start

And there we have it

Schermafbeelding 2017-01-04 om 22.09.07.png

Quitting the application can be done using the cmd-q shortcut.  At least on my Mac.  If you are trying this on windows, the procedure to do all this might differ a bit, but unfortunately i’m not familiar with it.




2 thoughts on “Running the smart mirror on my mac”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s