Tuesday, November 4, 2014

Local Installation of NightScout on Windows 7 and 8.1

I really like the NightScout CGM remote monitoring project. It has the potential to change, and has already changed, the lives of families with T1D kids. It's free, open source and actively developed. But when the gods of the Internet refuse to cooperate, it can be frustrating. Nightscout is a chain and every link has the potential to break. The uploader phone and cable, Internet connectivity to the database, access to the monitoring web site. We had such an incident this morning. Google browsing protection falsely flagged the sites hosted on Azure as malware. Bang, access denied, and a very alarming message to boot. For many families, the monitoring just stopped working.

 It doesn't have to be that way. Wouldn't it be nice to have a backup site? Well, nothing prevents you from adding a site to Heroku, Digital Ocean and other cloud providers. More instructions, more sign-ups, more passwords. Wouldn't it be even nicer to have a local backup site, on your own computer, that you can fire up instantly when you need it? Well, you can - and it is not difficult. Let's get started.

 1. Install node.js on your own computer 

Go to www.nodejs.org and download node.js - the web site will automatically offer a download link for your operating system. Install it, as you would install any other program.

2. open the node.js command prompt 

Go to the application menu. Right click on the item named "Node.js command prompt" and choose the "run as administrator option" (it is not absolutely mandatory to run as administrator, but it makes things easier at the last stage).

Keep that prompt open, we will soon need it.

3. install and download the cgm-remote monitor source code 

Create a folder for your local monitor by typing (for example)

mkdir c:\monitor-local 

 The folder can be anywhere, just keep its name and location in mind and adapt accordingly. Jump into the new folder by typing

cd \monitor-local

Now, we need the code for the server. Download the zip archive from Github - once it has been downloaded, open it and extract its content to the folder you have just created. You should see something like this in the folder, not the cgm-remote-monitor folder.

05-11-14  00:48    <DIR>          .
05-11-14  00:48    <DIR>          ..
05-11-14  00:48    <DIR>          'this
04-10-14  04:51                49 .bowerrc
04-10-14  04:51                33 .deployment
04-10-14  04:51               132 .gitignore
04-10-14  04:51               151 .travis.yml
05-11-14  00:48    <DIR>          a
04-10-14  04:51               273 app.json

4. prepare the node environment

 This is probably the only slightly difficult part. In order to run the server, we need a correct set of libraries. NPM - the node package manager will install them for us. In the console, type


You are likely to get the following error message

 Error: ENOENT. stat 'C:\Users\yourusername\AppData\Roaming\npm' 

Don't worry, it simply means a folder where NPM wants to work is missing. Let's create it. Type (you can simply copy and paste the path from the above error message)

mkdir 'C:\Users\yourusername\AppData\Roaming\npm' 

We are now ready to install all the libraries needed by the remote monitor. Make sure you are connected to the Internet and type

npm install 

You'll see cryptic lines go by and possibly a question about "Bower" to which you may respond either yes or no. At the end of the install, you should see something like this.

├── update-notifier@0.2.0 (semver-diff@0.1.0, string-length@0.1.2, latest-versio
n@0.2.0, configstore@0.3.1)
├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6)
├── inquirer@0.7.1 (figures@1.3.3, mute-stream@0.0.4, through@2.3.6, readline2@0
.1.0, lodash@2.4.1, rx@2.3.14, cli-color@0.3.2)
└── insight@0.4.3 (object-assign@1.0.0, async@0.9.0, chalk@0.5.1, os-name@1.0.1,
lodash.debounce@2.4.1, tough-cookie@0.12.1, configstore@0.3.1, inquirer@0.6.0)


5. configure the database 

Your server is now ready to run. It is only missing the mongo database configuration. Here you have two options, either use system variables or modify the database_configuration.json file. Type

notepad database_configuration.json 

You'll see this

 Edit the file so it contains your mongo connection strings - it should look like this

 Save the file.

6. run the server


node server.js 

If you typed your connection strings correctly, your server should start and you will probably be prompted by the Windows Firewall - allow your application to access the Internet. Your should then see something like the text on the left part of the image below. Your server is connecting to mongo and serving the data. In order to test it, fire up a browser and type, as a url, either localhost:1337 or 127.0.01:1337 (these are equivalent ways to have the browser connect to the local computer) - your portal will show up. You are done, or almost...

7. making it easy

Stop the server with CTRL-C (in general, you can only run one single server on a single port). As it stands, you'll need to open a command shell, move to the correct folder and type node server.js every time you want to start it. Not very convenient... Lets improve that a bit.

If you look at the properties of the node.js command shell, you'll see this

node.js comes with a batch file that sets its environment. We'll modify this batch file a bit to better suit our needs. Type

cd "\Program Files\nodejs\" 
notepad nodevars.bat 

Notepad will open and show this

Edit the last line and add one line as shown below.

The first yellow line makes sure you start your server in the correct directory. The second line starts the server from that directory. Save the file. Now, right click on the node.js command prompt link and create a shortcut to it on your desktop.

Whenever you click on that shortcut, your local server will run. You could still improve this a bit in terms of convenience, for example by launching a browser automatically or adding the server as a service so it runs all the time. Good Luck

Update January 19, 2015: local installation tested with the 0.6 Dreamsicle release. Still works.


  1. How do I get my son's dexcom data on my PC desktop? I have followed the instructions above all the way to the part that says I need to enter my mongodb information. What is that and where do I get a mongodb setup?

  2. It´s not accept the apisecret to show the default-Profile... :-(

    1. That blog post is more than 3 years old, the program has probably changed a lot since. Sorry about that!


Note: Only a member of this blog may post a comment.