This is a good example of an online IDE. These enable you to do software development without needing to install anything on your computer. They are also ideal for use with a Chromebook. You need to sign up for an account on their website, sign in and access the dashboard page. Click on the Create a New Container button.
You will be presented with a screen where you can name your project and choose a software stack:
You should see an IDE that displays the files down the left side with an editor in the main view and a terminal window below:
The next step is to clone the repository containing the lab materials into the IDE. Start by opening the GitHub page. Locate the Clone or download button, clicking this pops open a small window as shown. Copy the URL in this window to your clipboard.
Returning to the IDE, run the following command in the terminal:
git clone https://github.coventry.ac.uk/340CT-1819SEPJAN/TEACHING-MATERIALS.git labs
This creates a labs/
directory containing all the files from the repository.
By default real-time linting is enabled however this currently uses an old linter and is not ECMA6 compatible. You should disable real-time linting from the Project menu.
We can see the current version of NodeJS by running the node -v
command. The latest version is 10.11.0 and so we need to upgrade this.
Start by installing the Node Version Manager tool:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Now click on the small blue oval on the terminal tab to reload the shell. There are lots of versions available, use the nvm list-remote
command to see these. Install the latest using nvm install 10.11.0
substituting the latest version number. To check the version installed use node -v
again.
Use the terminal to navigate to the simple_templating
directory and try running the index.js
script:
$ cd labs/exercises/01_nodejs/01_templates_forms/simple_templating
$ node index.js
Error: Cannot find module 'express'
Notice you get an error, we need to install the missing module using the Node Package Manager tool. We can then try to run the script again:
$ npm install express
$ node index.js
Error: Cannot find module 'express-handlebars'
We get a different error explaining that there is another missing module:
$ npm install express-handlebars
$ node index.js
app listening on port 8080
Now we have the server up and running so the final task is to view the web page using the web browser.
This will open a window where you will need to register a new URL and port:
- Use your University Username as the URL segment.
- Make sure you specify port 8080 (this is the one used by your server).
You need to set this up as your run configuration as shown.
The final step is to open a new browser window and enter your chosen URL, you don't need to specify the port, this was done through port-forwarding:
If you make changes to the code or want to quit the IDE you will need to stop the server. To do this, select the terminal window and press ctrl+c.
Before you can work with Git you need to update the repository configuration. Follow the instructions below:
- Update your name (this must be the name as it appears on your ID badge) using
git config user.name 'Joe Bloggs'
. - Update your email (using your unversity email)
git config user.email 'bloggsj@uni.coventry.ac.uk'
- Update your commandline editor choice using
git config core.editor nano
(the editor must be installed!) - Cache your credential (username/password) for an hour using
git config credential.helper 'cache --timeout=3600'