npm (Node Package Manager) is a package manager for JavaScript, commonly used with Node.js.  

On IBM i, NPM is exactly the same beast you know from the Linux / Windows world… just running inside the PASE environment.

npm allows developers to share and reuse code, as well as manage project dependencies. 

What NPM is (in human language)

NPM stands for Node Package Manager.

It is:

  • A package manager for Node.js
  • A tool used to install, update and manage JavaScript libraries
  • Basically the “yum / apt / RPM” of the Node.js ecosystem

If you’re writing Node.js on IBM i, you’ll use NPM constantly.

Here’s how npm works on the IBM i system:

Installation

To use npm on IBM i, you first need to install Node.js. This can be done through the IBM i Open Source Solutions (5733OPS) licensed program1. Once Node.js is installed, npm is typically included by default.

Key Features

  • Package Management: npm allows you to install, update, and manage JavaScript packages. This is particularly useful for managing dependencies in your Node.js applications.
  • Script Running: You can define scripts in your package.json file and run them using npm. This is useful for automating tasks like testing, building, and deploying your applications.
  • Version Control: npm helps in managing different versions of packages, ensuring compatibility and stability in your projects.

Where it lives on IBM i

NPM runs inside PASE (Portable Application Solutions Environment).

That means:

  • It is not native ILE code
  • It runs alongside AIX-type tooling
  • It uses the same filesystem (IFS)

Typical path:

/QOpenSys/pkgs/bin/npm

And Node itself:

/QOpenSys/pkgs/bin/node

These come from the IBM i Access Client Solutions (5733-OPS) Yum repository.

How you actually use it

From an SSH session or QP2TERM, you’ll do things like:

Check version

npm -v
validate NPM

Usage on IBM i

Installing Packages: You can install packages from the npm registry using the npm install command.

For example, to install the express package, you would run:

npm install express

Running Scripts: Define scripts in your package.json file and run them using npm run.

For example, to start your application, you might have a script like:

"scripts": {
"start": "node app.js"
}

You can then run it with:

npm run start

Accessing IBM i Resources:

There are npm packages specifically designed to interact with IBM i resources.

For example, the itoolkit package allows you to call RPG, CL, and other IBM i programs2.

Example Workflow

  • Set Up Node.js and npm: Install Node.js and npm on your IBM i system.
  • Initialize a Project: Create a new project with npm init, which will generate a package.json file.
  • Install Dependencies: Use npm install to add necessary packages.
  • Develop and Test: Write your application code and use npm scripts to automate testing and other tasks.
  • Deploy: Deploy your application using npm scripts or other deployment tools.
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>