Package Managers

Node.js Package Managers

Each Node.js application server includes out-of-the-box support for npm and Yarn. Both package managers use the npm registry and automate package installation, updates, configuration, and removal.

Node.js package managers
Node.js application servers support npm and Yarn package managers.

Package-Manager Overview

Package ManagerPurposePlatform Behaviour
npmManages additional modules, packages, and ready-to-use Node.js applications.Used by default for archive and Git deployment through the dashboard.
YarnProvides an alternative package-management workflow focused on speed, reliability, and convenience.Uses the same npm registry and the same package.json requirements as npm.

Switch Between npm and Yarn

1

Open the container settings

Locate the Node.js application server and open its container settings or variables section.

2

Set the package manager

Set the PACKAGE_MANAGER container variable to either npm or yarn.

Node.js package manager variable
Set PACKAGE_MANAGER to npm or yarn in the container variables.

No application rewrite is required

Yarn uses the same package.json file as npm, so existing Node.js projects do not need to be restructured when changing the package manager.

Node Package Manager (npm)

There are two supported ways to install the packages required by a Node.js project.

Method 1: package.json Dependencies

Add the required modules to the dependencies section of the project’s package.json file. npm automatically downloads and installs them during application-server startup. Newly added dependencies are installed after the Node.js node is restarted.

Method 2: Manage Packages through SSH

Connect to the container through SSH Gate and use these commands:

npm search {package_name}
npm install {package_name}
npm uninstall {package_name}
npm update {package_name}
npm ls installed
CommandPurpose
npm search {package_name}Search for modules by their full name or part of the name.
npm install {package_name}Install the required module.
npm uninstall {package_name}Remove a previously installed module.
npm update {package_name}Update the specified module to its latest available version.
npm ls installedList the already installed packages, as documented by the source page.

Yarn Package Manager

Yarn operates with the same Node.js package.json file as npm. Connect to the container through SSH and use these commands:

yarn
yarn install
yarn remove {package}
yarn add {package}@{version}
yarn upgrade {package}@{version}
yarn list
CommandPurpose
yarn or yarn installInstall all dependency packages required by the project.
yarn remove {package}Remove the specified package.
yarn add {package}@{version}Add a package to the dependency list and install it. The version is optional; the latest is used by default.
yarn upgrade {package}@{version}Update the package. A specific version can be supplied as an optional argument.
yarn listDisplay all installed packages.

Expected Result

The Node.js container uses the selected npm or Yarn package manager. Project dependencies can be installed automatically from package.json or managed manually through SSH commands.

Important Notes

  • npm is the default package manager for archive and Git deployment.
  • Use the PACKAGE_MANAGER variable to switch to Yarn.
  • Restart the Node.js node after adding new dependencies to package.json when relying on startup installation.
  • Yarn and npm use the same package registry and project requirements.
  • Run manual package commands from the correct project directory.
  • Use a lock file appropriate to the chosen package manager for consistent deployments.