In this lab, you’ll start from scratch to install Node.js and the components of the API Connect Developer toolkit. Once you have the toolkit installed, you’ll get a chance to use the APIC command line interface for creating LoopBack applications, the intuitive Web-based user interface, and explore the various aspects associated with solution’s configuration of RESTful based services as well as their operation.

Objective

In the following lab, you will learn:

  • How to install Node.js on to your machine
  • How to enable API Connect on your Bluemix account
  • How to install the APIC Developer Toolkit

Case Study used in this tutorial

In this tutorial, you will be starting from scratch to set up your development environment on your local machine.

Before you begin

For this lab, you will be starting with your local image and installing node.js and the developer toolkit. After that, if you do not already have a Bluemix account, you will be creating one for you and enabling the API Connect Essentials service on your account. The instructions you will follow will vary by the host operating system you are using. The three host OS’s supported by this are Windows, Linux - Intel and Linux - Mac. Skip to the section for your appropriate operating system.

Step by Step Lab Instructions

0.1 - Install Node.js

0.1a - Windows

  1. If you don’t have node already installed on your machine, then please proceed. Otherwise, move on to section 0.2 (Setup your Bluemix account).

  2. Installing Node on Windows based machines (Tested on Windows 7 and Windows 10):

  3. The following are pre-requisites that need to be installed before installing node:

    1. Install Python

      1. version 2.7 is required. You can download it here:

        https://www.python.org/download/releases/2.7/

      2. Note the location where it is installed. You will need to add this location to your path later on.

    2. Install .Net Frameworks SDK 2.0

      https://www.microsoft.com/en-us/download/confirmation.aspx?id=19988

    3. Install Visual Studio Express

      https://www.microsoft.com/en-us/download/confirmation.aspx?id=44914

    4. Add Python to the System Path in Windows 7 to the System Path.

      1. Go to Control Panel -> System -> Advanced System Settings

      2. Click Environment Variables.

      3. Click Edit and append ;C:\python27 (or wherever you installed python) to the Path variable.

  4. Install Node.js

    1. Go to this link to install Node:

      https://nodejs.org/en/download/

    2. Select the “LTS version - Recommended for most users”. Version at the top should depict v4.5 - includes npm 2.15.9.

    3. Select the Windows Installer .msi binary and then follow the prompts to install on your machine.

    4. Before moving on, You will need to update your version of npm to version 3.8.10

    5. To do so, perform the following steps:

    6. Click on Start and then in the search window type in Powershell. Right click on Windows PowerShell and then select Run as Administrator

    7. Execute these commands in Powershell

      Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
      npm install -g npm-windows-upgrade
      npm-windows-upgrade
      
    8. Select the 3.10.8 version of npm. This is the recommended version to run with. Close the Powershell.

  5. Install API Connect on to your machine by starting up a command line window as Administrator and issue this command:

    npm install -g apiconnect --no-optional --ignore-scripts
    
  6. Once complete start up a new terminal window and enter in apic -v.

    If it returns the version of the platform, and not an error message, then the toolkit should then be properly installed.

  7. You are now ready to move on to section 0.2.

0.1b - Linux

  1. Install the essentials to run node.js:

    sudo apt-get install build-essential libssl-dev curl git-core
    
  2. Install Node Version Manager aka “nvm” by issuing this command here:

    curl https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
    
  3. Close and restart your terminal as indicated in the terminal window or run this command source ~/.profile.

  4. Run this command to confirm your version nvm --version

  5. This command will provide documentation on nvm if you wish to learn more about it nvm help. NVM is exceptionally useful as it will allow you to support multiple installations of node.js on your machine, and select the version you want to use. For our lab today, we only need the one version as indicated in the steps below.

  6. To check and see which versions of node are available, issue this command nvm ls-remote. It will provide a very long list. For API Connect, we will use a specific version of node. That is version 4.5.0

  7. To install node 4.5.0 issue this command nvm install 4.5.0

    student@ubuntu:~$ nvm install 4.5.0
    Downloading https://nodejs.org/dist/v4.4.7/node-v4.5.0-linux-x64.tar.xz...
    Now using node v4.5.0 (npm v2.15.9)
    
  8. Install API Connect by issuing this command:

    npm install -g apiconnect
    

    It will take several minutes to complete.

  9. Once complete start up a new terminal window and enter in apic -v.

    If it returns the version of the platform, and not an error message, then the toolkit should then be properly installed.

  10. You are now ready to move on to section 0.2.

0.1c - Mac OS

  1. Check to see if node is already installed.

    node -v
    
  2. Check the version, if it is version 4.5.0 then you can move on to section 1.1 - Create your Bluemix account. However if you would prefer to uninstall and reinstall node using Node Version Manager or if node was not found then please continue.

  3. Remove any existing versions of node. You will only need to complete these steps if node currently exists. To remove node completely from your Mac OSX environment run each of the following commands. Open a terminal session and type each of the commands below individually.

    sudo rm /usr/local/bin/npm
    sudo rm /usr/local/share/man/man1/node.1
    sudo rm /usr/local/lib/dtrace/node.d
    sudo rm -rf ~/.npm
    sudo rm -rf ~/.node-gyp
    sudo rm /opt/local/bin/node
    sudo rm /opt/local/include/node
    sudo rm -rf /opt/local/lib/node_modules
    sudo rm -rf /usr/local/include/node/
    
  4. Install Xcode Command Line Tools. Open a terminal and type

    xcode-select --install
    
  5. This will open a dialog informing you that the command line developer tools are required for install. Press the Install button.

  6. Agree to the license

  7. The software install will begin

  8. The install is complete when you see the “The software was installed” message.

  9. Next install git. You may already have a version, but if you want to have the latest version you will need to download the install from https://git-scm.com/download/mac

  10. Once on the install page the download should start immediately. However if it does not start immediately, click the “click here to download manually” link.

  11. Once the download has completed, you should have a file named similar to git-2.8.1-intel-universal-mavericks.dmg. Double-click to unpack the disk image.

  12. Once the disk image is unpacked and open, double-click the git-2.8.1-intel-universal-mavericks.pkg file. Note that if you downloaded a different version the file name will be reflected accordingly.

  13. You may get a dialog box with a message stating that the file can’t be opened because it is from an unidentified developer. Click the OK button. Open your System Preferences and select the Security & Privacy component. In the section called “Allow apps downloaded from:” you will notice a message that states ‘“git-2.8.1-..ericks.pkg” was blocked from opening because it is not from an identified developer.’, press the Open Anyway button. This will open the installer for git.

  14. Follow the wizard to install. The installation is complete when you see a message stating that the installation was successful.

  15. Install Node Version Manager aka “nvm” by opening a terminal session and typing the following commands:

    git clone git://github.com/creationix/nvm.git ~/.nvm
    printf "\n\n# NVM\nif [ -s ~/.nvm/nvm.sh ]; then\n\tNVM_DIR=~/.nvm\n\tsource ~/.nvm/nvm.sh\nfi" >> ~/.bashrc
    NVM_DIR=~/.nvm
    source ~/.nvm/nvm.sh
    nvm install 4.5.0
    nvm alias default node
    nvm use node
    

    Note: You may want to update your .bash file so you do not have to source the shell script every time. To do that, add the following to your .profile located in your user home directory:

    export NVM_PATH=~/.nvm
    source ~/.nvm/nvm.sh
    
  16. Install API Connect by issuing the following command:

    npm install -g apiconnect
    

    It will take several minutes to complete.

  17. Once complete start up a new terminal window and enter in apic -v.

    If it returns the version of the platform, and not an error message, then the toolkit should then be properly installed.

  18. You are now ready to move on to section 0.2.

0.2 - Create your Bluemix account

  1. Open a browser and visit:

    http://www.bluemix.net

  2. Press the SIGN UP button

  3. Complete the form and press the CREATE ACCOUNT button

  4. Check your email for your next steps.

  5. Open the email and click the Confirm your account link.

  6. Once confirmed, you will be taken to a page that says Success! To login, click the Log In link

  7. Enter your email address and press the CONTINUE button

  8. Then enter your password on the next page and press the LOG IN button

  9. Once you are logged in, you can start your 30 day trial by clicking on the launch button.

  10. You will be prompted to create an organization. Enter an organization name (notice that there are suggestions for you). Also select an appropriate region. Then press the CREATE button.

  11. Next you will be prompted to create a space such as dev, test, prod, etc. You can name it whatever you would like (again notice the recommendations). Then press the CREATE button.

  12. Next you will see the Summary page where you can review your entries. Press the I’m Ready button

  13. You will see a screen then that Click the Catalog button to go to your catalog and create your API Connect instance in section 0.3 below.

0.3 - Enable the API Connect Service on your Bluemix Account

  1. Once in the catalog, you can search for the API Connect service by entering in API Connect in the search box next to the magnifying glass icon. Click on the API Connect Icon to install a new instance of API Connect into your Bluemix space.

  2. You can read through some of the details about the service. You can fill in the information based on your needs.
    • SPACE – The name of your Bluemix Space to deploy the API Connect Service
    • APP – Keep the default “Leave unbound”
    • Service Name – The name you want to give to your API Connect implementation if required
    • Selected Plan – Keep the default Once you are ready to continue, Click the Create button.

  3. The API Connect service is now deployed. Return to your Dashboard and you will see that your API Connect service is there. Click on it open.

  4. It will log into your instance for you automatically. Once finished, it should drop you in your Drafts window.

  5. Click on the Navigate button in the upper left corner and select Dashboard. If you see your Sandbox catalog there, then the process to create your instance is complete.

0.4 Create your Developer Portal Instance for your API Connect Catalog

  1. Open a new tab in your web browser by clicking on the new tab + button.

  2. Log into your Bluemix Account using this url: https://new-console.ng.bluemix.net/
  3. Via the dashboard, click on your API Connect instance.

  4. From the top left, go to the Dashboard to bring your list of catalogs. Click on your Sandbox Catalog

  5. Click on Settings

  6. Here you will see that you have no developer portal set up.

  7. Select the IBM Developer Portal Radio Button to create your own custom portal that is tied to your catalog and then click Save. It will automatically generate the portal URL and the portal as well.

  8. A pop up screen will let you know that the process to create your portal has started.

  9. It might take some time for your developer portal to get created, but usually the process is pretty quick. If this piece doesn’t work for you right away, move on to the next lab and circle back to this lab in a bit. Once the portal is done creating, you will receive an email. If it still doesn’t work by the time you get to the later labs, inform your instructor.

  10. Once the process is complete, click on the link of the portal URL as seen in the screenshot above in step #9. It is highly suggested that you create a bookmark for your developer portal in your browser so you can get back to it easily later.

Conclusion

Congratulations! You have installed node.js, the API Connect developer toolkit!

In this lab you learned:

  • How to install node.js and its prerequisites and the API Connect Developer Toolkit on your native OS.
  • Set up you Bluemix Account.

Options: Either