Package Managers
Each created Node.js application server within the platform is provisioned with out-of-box support of two main package managers for this language - Yarn and npm. Both of them operates the same npm registry with a broad collection of the dedicated software packages, providing standardization and automation of the installation, update, configuration and removal processes.
By default, the npm package manager will be used for archive or Git deployment operations through the platform dashboard, but it can be easily switched to the yarn one in case of necessity. For that, access the corresponding Docker container settings frame and set the appropriate PACKAGE_MANAGER Docker container variable to either npm or yarn value.
Below, we’ve gathered some basics on operating these managers, intended to help you on determining which one suits you best:
Node Package Manager (npm)
Node Package Manager (npm) can be used for managing additional modules and packages, required for your project, as well as for installation of the ready-to-use applications.
There are two ways to install necessary Node.js packages with npm:
-
Specify required ones within the dependencies section of the NodeJS package.json file, located in the root directory of your project. Such packages will be automatically downloaded and installed by npm during application server startup. Herewith, the new modules specified in the package.json file will be added after NodeJS node restart.
-
Connect to the container via SSH Gate and operate your packages manually with the following commands:
npm search {package_name}
- to search for modules by name (or its part)npm install {package_name}
- to install the necessary modulenpm uninstall {package_name}
- to remove the previously installed modulenpm update {package_name}
- to update the specified module to its latest versionnpm ls installed
- to list already installed packages
Yarn Package Manager
Yarn is a recently released package manager, which is already highly popular due to its speed, reliability and convenience. Yarn operates the same NodeJS package.json file as in npm, so no changes are required for the existing applications.
You can use the following list of commands to work with Yarn, while connected over SSH:
yarn
oryarn install
- to get all dependencies package for the projectyarn remove {package}
- to remove the specified packageyarn add {package}@{version}
- to add a new package to the dependencies list and install it; optionally, you can specify a particular version as an argument (the latest one will be used by default)yarn upgrade {package}@{version}
- to update package to its latest version; optionally, you can specify a particular version as an argumentyarn list
- to list all of the installed packages