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.
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
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
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 :
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
And there we have it
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.