Skip to content

Setting up local dev environment for Node

Emil Rose edited this page Apr 6, 2016 · 4 revisions

Setup

These instructions should work for Linux and OS X. If you're using Windows, you'll have to make appropriate adaptations.

First, clone the repository. IMPORTANT: The repository contains the ace-build repository as a submodule, so you must clone with the recursive flag.

git clone --recursive https://github.com/Sable/McLab-Web.git

If you do not have npm and node, you will need to install them. See https://docs.npmjs.com/getting-started/installing-node for installation instructions. McNode has been tested and should work for both 4.3.1 and 5.6.0. Once node and npm are installed, install all the javascript dependencies:

npm install

We need to set up our config file: Copy the example settings file first:

cp mcnode/config/config.example.js mcnode/config/config.js

Make sure you have McLab Core and Mc2For somewhere on your computer (see https://github.com/Sable/mclab-core/wiki/Installation for McLab Core installation instructions. You can download the Mc2For jar from http://www.sable.mcgill.ca/mclab/projects/mc2for/ or the mc2for github repo.) Edit the newly created config.js file and edit the values of MCLAB_CORE_JAR_PATH and MC2FOR_PATH to point to the two jar files. Using absolute paths will save you a lot of headache. Do not use "~" for home directory. You will also need a Google API key for shortening links; you can ask Emil for his or generate one here.

We need to compile our JavaScript, because the JS code is written in JSX syntax and uses some ES6 features not yet supported natively by the browser.

npm run watch

Wait for a message like 5580706 bytes written to static/bundle.js (7.40 seconds) - this can take up to a minute.

npm run watch starts a watch job that will recompile the javascript if you make any change, so it is useful to keep it running. Open a new terminal window where we will start our server!

    # Open a new terminal window first
   
    # Go to the mclab folder
    cd /path/to/mclab-web

    # Start the server. About time!
    npm start

Node should tell you where it is serving your site (most likely at localhost:3000). Open a browser and go to that address - you should see McNode running.

Testing everything works

Go through the testplans.

Troubleshooting

If the site does not work as expected, you have two logs to help you understand what went wrong - the node logs for any server side trouble (they will be displayed in the same terminal where you started the server.), and the js logs for client side trouble (open up chrome developer console).