Getting Started with Node.js

Introduction

This guide shows how to install and use the Node.js edition of the components in Node.js. This is applicable to both Windows and Linux. The usage is similar to all other node packages, and getting started is quick and easy.

Contents

  1. Installation
  2. Async Calls
  3. Errors

Installation

To begin first download the toolkit from our website. Next use npm to install from the tarball. For example:

npm install ipworks-9.0.tar.gz

The components have a dependency on only one other node package, which is fibers. This will be automatically downloaded by npm when the command above is executed.

After installing, demos and help files may be found in the product folder. For instance node_modules/ipworks/demos and node_modules/ipworks/help.

Async Calls

Using the components is similar to any other node package. If you have worked with Node.js in the past the way the components are designed and operate will be familiar to you.

All properties and methods of the components can operate asynchronously. For example, below is fully functional code that you can try out:

var ipw = require('ipworks');
var ftp1 = new ipw.ftp();

ftp1.on('PITrail', function(e){
  console.log(e.message);
});

ftp1.setRemoteHost('ftp.mozilla.org', function(err){
  ftp1.setUser('anonymous', function(err) {
    ftp1.setPassword('anonymous', function(err) {
      ftp1.logon(function(err) {
        if(err){
          console.log('There is an error: '+ err);
          return;
        }
        else {
          console.log('Logged on!');
        }
      });
    });
  });
});

If no callback is provided to the property or method, then the call will operate synchronously and will block until the operation completes or there is an error.

Errors

The components use the common error-first callback approach. The first argument of the callback is the error object. The error object has two properties that hold details about the error: err.code and err.message


We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.