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
-
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).
-
Installing Node on Windows based machines (Tested on Windows 7 and Windows 10):
-
The following are pre-requisites that need to be installed before installing node:
-
Install Python
-
version 2.7 is required. You can download it here:
https://www.python.org/download/releases/2.7/
-
Note the location where it is installed. You will need to add this location to your path later on.
-
Install .Net Frameworks SDK 2.0
https://www.microsoft.com/en-us/download/confirmation.aspx?id=19988
-
Install Visual Studio Express
https://www.microsoft.com/en-us/download/confirmation.aspx?id=44914
-
Add Python to the System Path in Windows 7 to the System Path.
-
Go to Control Panel
-> System
-> Advanced System Settings
-
Click Environment Variables
.
-
Click Edit
and append ;C:\python27
(or wherever you installed python) to the Path variable.
-
Install Node.js
-
Go to this link to install Node:
https://nodejs.org/en/download/
-
Select the “LTS version - Recommended for most users”. Version at the top should depict v4.5 - includes npm 2.15.9.
-
Select the Windows Installer .msi binary and then follow the prompts to install on your machine.
-
Before moving on, You will need to update your version of npm
to version 3.8.10
-
To do so, perform the following steps:
-
Click on Start
and then in the search window type in Powershell
. Right click on Windows PowerShell
and then select Run as Administrator
-
Execute these commands in Powershell
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
-
Select the 3.10.8
version of npm. This is the recommended version to run with. Close the Powershell.
-
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
-
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.
-
You are now ready to move on to section 0.2.
0.1b - Linux
-
Install the essentials to run node.js:
sudo apt-get install build-essential libssl-dev curl git-core
-
Install Node Version Manager aka “nvm” by issuing this command here:
curl https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
Note:
When you install nvm
it will also install npm
which is the node package manager used to install node.js based software modules, including the API Connect Developer Toolkit.
-
Close and restart your terminal as indicated in the terminal window or run this command source ~/.profile
.
-
Run this command to confirm your version nvm --version
-
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.
-
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
-
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)
-
Install API Connect by issuing this command:
npm install -g apiconnect
It will take several minutes to complete.
-
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.
-
You are now ready to move on to section 0.2.
0.1c - Mac OS
-
Check to see if node is already installed.
-
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.
-
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/
-
Install Xcode Command Line Tools. Open a terminal and type
-
This will open a dialog informing you that the command line developer tools are required for install. Press the Install button.
-
Agree to the license
-
The software install will begin
-
The install is complete when you see the “The software was installed” message.
-
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
-
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.
-
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.
-
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.
-
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.
-
Follow the wizard to install. The installation is complete when you see a message stating that the installation was successful.
-
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
-
Install API Connect by issuing the following command:
npm install -g apiconnect
It will take several minutes to complete.
-
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.
-
You are now ready to move on to section 0.2.
0.2 - Create your Bluemix account
-
Open a browser and visit:
http://www.bluemix.net
-
Press the SIGN UP button
-
Complete the form and press the CREATE ACCOUNT button
-
Check your email for your next steps.
-
Open the email and click the Confirm your account link.
-
Once confirmed, you will be taken to a page that says Success! To login, click the Log In link
-
Enter your email address and press the CONTINUE button
-
Then enter your password on the next page and press the LOG IN button
-
Once you are logged in, you can start your 30 day trial by clicking on the launch button.
-
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.
-
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.
-
Next you will see the Summary page where you can review your entries. Press the I’m Ready button
-
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
-
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.
- 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.
-
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.
-
It will log into your instance for you automatically. Once finished, it should drop you in your Drafts window.
-
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
-
Open a new tab in your web browser by clicking on the new tab +
button.
- Log into your Bluemix Account using this url: https://new-console.ng.bluemix.net/
-
Via the dashboard, click on your API Connect instance.
-
From the top left, go to the Dashboard
to bring your list of catalogs. Click on your Sandbox
Catalog
-
Click on Settings
-
Here you will see that you have no developer portal set up.
-
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.
-
A pop up screen will let you know that the process to create your portal has started.
-
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.
- 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