Installing‎ > ‎

Install NodeJS

Node.js is a popular JavaScript-based runtime. It provides a common language for client and server coding, with a rich ecosystem of packages based around the npm install command. Use the information on this page to install Node.js and related Live API Creator support. You do not need a Node.js background to install Node.js using these installation proceduresThis page also includes an overview of Node SDK, Command Line Interface (CLI), and Admin CLI usage.

You use the package installation in the following ways:

  • Normal. Provides services for (normal) Node.js/JavaScript coding.
  • CLI. Create tools for command line extensions in Windows command files and Unix shell scripts, for example, for DevOps scripting.

Node.js and Live API Creator

Use the following process to install Node.js and Live API Creator support:

  1. Install Node.js.
  2. Install the following Live API Creator npm packages:
    Note: These package are required for the Business to Business Example but recommended for general API Creator use.
    •  The APICreatorSDK Node SDK. For writing Node.js programs.
    • The CLI (liveapicreator-cli). For command line access to your API project.
    • The Admin CLI (liveapicreator-admin-cli). For command line access to your Admin database.

Install Node.js

Node.js is required for Node.js programming and Live API Creator. Install the Node.js version that Live API Creator supports (Node.js 4.x (not Node.js 5.x). You can install Node.js by way of brew or installers.

Caution! In some cases, the latest Node.js version may not be compatibleThese packages do not install properly if you are using Node 5.0 or later. We recommend Node version 4.1.

Note: npm installs apply to all sub folders. They are not inherently global to your machine. If you have installed the single-user demonstration package that is based on Jetty, to make the Live API Creator npm packages available to your package installation and APIs, we recommend performing these installs from your lac folder that you created when installed the single-user demonstration package. For more information about this folder, see Install the Single-User Demonstration Package.

For more information:

Install the APICreatorSDK Node SDK

Use the APICreatorSDK Node SDK for writing Node.js programs and for simplified data access from Node.js programs. This npm package provides a number of useful methods for working with the API projects you create using API Creator.

Issue the following npm install command from the command line:

npm install APICreatorSDK

Note: Do not use the -g option.

For more information about how to install the Node SDK, how to try out the library, and how to connect to an existing API project, see the npm site.

Node SDK Usage

This example is drawn from the Business to Business (B2B) example. They are further described on the npm site.

For more information about the B2B example, see Business to Business Example.

The following code snippet is an example from the b2bscripts/scs/projects/test/node/verify.js file:

var api = apicreator.connect('http://localhost:8080/rest/default/b2bderbynw/v1', 'Bzn8jVyfOTiIpW6UQCgy');
var ordersEP = api.endpoint('nw:Orders');
ordersEP.get('sysfilter=equal(OrderID:2000)').then(function (data) {
  var theOrder = data[0];
  if (theOrder.AmountTotal == 301.20 && theOrder.discountedAmount == 298.188) {
  console.log("....Success...");
}
  else {

    console.log("** Expected values not found, theOrder...");
  }
});

For more information about how to use Node SDK, including API and endpoint object methods, see Use Node SDK.

Install the Command Line Interface

Use the liveapicreator-cli CLI for command line access to your API project and to access your data from shell/command scripts.

Prerequisite: (Windows) To avoid having to specify the full path to the executable, you have added the Node.js location of the directory to the Variable Value field of the PATH user variable. If the PATH variable is not in your list of User variables, then create a new one.

(Windows) Issue the following npm command from the command line:

npm install -g liveapicreator-cli

Important! The npm install command creates an executable called liveapicreator (or lac as a shortcut) in your <node_modules>/.bin directory. To prevent having to specify the full path to the executable, this directory must be in your PATH.

For more information about adding the <node_modules>/.bin directory in your PATH, see Configure Windows Path.

(Unix and Mac) Issue this command, (depending on your admin rights, with sudo), as follows:

sudo npm install -g liveapicreator-cli

For more information about the CLI, including how to install the CLI, how to access the CLI help, and viewing sample scripts, see the npm site.

Command Line Interface Usage

This example is drawn from the Business to Business (B2B) example. They are further described on the npm site.

For more information about the B2B example, see Business to Business Example.

The following code snippet is an example from the /b2bscripts/scs/projects/test/node/postAndVerify.sh file and shows how to log in and use the AuthID for multiple commands. Access the CLI as liveapicreator (or lac) commands:

#! /bin/bash
liveapicreator login -u demo -p Password1 http://localhost:8080/rest/default/b2bderbynw/v1 -a b2b

# Post and read order to b2b Partner

liveapicreator post PartnerOrder -j '{ "CustomerNumber": "VINET","Items": [ {"ProductNumber": 16, "Quantity": 1 },{"ProductNumber": 7,"Quantity": 2}, {"ProductNumber": 14, "Quantity": 3}, {"ProductNumber": 10, "Quantity": 4}, {"ProductNumber": 13, "Quantity": 5} ] }'

lac
get nw:Orders -f 'equal(OrderID: 2000, AmountTotal: 301.20)' --format json

Install the Admin Command Line Interface

Manage your admin services, such as your API projects, resources, and rules, from shell/command scripts using the Admin CLI, liveapicreator-admin-cli.

(Windows) Issue the following npm command from the command line:

npm install -g liveapicreator-admin-cli

(Unix and Mac) Issue this command with sudo, as follows:

sudo npm install -g liveapicreator-admin-cli

For more information about the Admin CLI, including how to install the Admin CLI, how to access the Admin CLI help, and viewing a sample export and import script, see the npm site.

Admin Command Line Interface Usage

This example is drawn from the Business to Business (B2B) example. They are further described on the npm site.

For more information about the B2B example, see Business to Business Example.

The following example shows how to import the b2bnwderby.json file using the Admin CLI. Access the Admin CLI as lacadmin (or liveapicreatoradmin) commands: 

lacadmin project import --file ../src/b2bnwderby.json

This example is from the following files:

(For Mac) b2bscripts/scs/projects/b2b/build/importnwb2b.sh
(For Windows) b2bscripts/scs/projects/b2b/build/importnwb2b.cmd

More Information

For more information:

  • About scripting the meta tag information using the CLI, including viewing the complete list of system REST endpoints you can script, see System REST Endpoints.
Subpages (1): Configure Windows Path