To learn how to install API Connect on Windows 7 with IBM SDK Node.js, click here

Overview
Many developers work with multiple versions of node.js.
Here are some best practises of how to manage and use multiple versions of IBM SDK Node.js on windows.

Current environment
I have installed 2 versions of IBM SDK Node.js
Node version 4.4.5 at C:\Users\Administrator\IBM\node4 and npm version is 2.15.9.
Node version 6.6 at C:\Users\Administrator\IBM\node6 and npm version is 3.10.3
NPM prefix at C:\Users\Administrator\AppData\Roaming\npm


node-install-multipe6

Installing IBM SDK Node.js 4.5

To install a new version of node.js, download from IBM SDK Node.js Download URL

From the installer, choose the following options:

    1. Start a command line prompt and execute installer


node-install-wininstaller

    1. Select install a new instance


node-install-1

    1. Select a new installation location at C:\Users\Administrator\IBM\node45


node-install-node45location

    1. Specify ShortCut to new Program Group


node-install-shortcut

    1. Press Next and review install summary and then install


node-install-node-summary

    1. Install is done with the success completion


node-iinstall-success

Choosing the IBM SDK Node.js Command Prompt

  1. Start Menu->All Programs
  2. Now we have 3 version of IBM SDK Node.js
    screen-shot-2016-09-23-at-11-59-11-pm
  3. Choose the specific version Node of Program Group
  4. Expand the Program Group
  5. Select the Node.js Command Prompt
  6. Echo %PATH%
  7. You will find that the Specify version of Node version is setup in the path


screen-shot-2016-09-23-at-11-45-37-pm

Installing apiconnect globally

In the Node.js Command Prompt, set NPM Cache for each Node.js version
npm registry set cache=C:\Users\Administrator\AppData\Roaming\npm-cache6
I am using the default npm-prefix which is already setup in the PATH
There are two ways to install apiconnect.

  1. From npmjs.org
    npm install -g apiconnect –no-optional –ignore-scripts
  2. apiconnect bundle
  3. npm install -g apiconnect-.tgz –no-optional –ignore-script

Note: –ignore-scripts is a workaround for version 5.0.4.0

The resulting environment
Now I have 3 versions of IBM SDK Node.js on 3 different locations.
Each Node.js version is packaged with a specific npm version.

screen-shot-2016-09-24-at-5-28-05-pm

In Summary:

  • Always use the IBM SDK Node.js Command Prompt, it nicely setup the Node version in the PATH.
  • Before you install globally in each Node.js version.
    • set unique npm-cache for each node version
    • set unique npm-prefix for each node version
    • set npm-prefix in %PATH%
  • npm -v and node -v to confirm your environment.

Tips:
When run into unexpected errors installing apiconnect, try following things:

  1. echo %PATH% to check your settings
  2. npm cache clean
  3. npm config get prefix to get current npm-prefix
  4. Manually remove the npm-cache folder

Join The Discussion

Your email address will not be published. Required fields are marked *