Nowadays every programming language has one or more package managers, but first let's explain this. It's a command line tool that allows us to add software packages to a project, that are public and high quality. Also we can track versions of packages and install all necessary dependencies. Programming languages such as php has composer and for nodejs and javascript source code are npm and yarn.

Whas is NPM

Npm is the default package manager for nodejs, we can search and browse available packages in the official website When we use npm in a project first we have to create an important file  that is named package.json, this will contain the list of packages that we will use, the source code always  i stored in a folder called node_modules. Creating this file is easy just by typing the command.

npm init

When we push new code to the repository of our project, usually the we do not save the files from node_modules folder there, we only add main file package.json. In case we want to install the project to another computer we just cloning the repository and then reninstalling packages by typing in cli the following.

npm install

Some of the popular packages of npm is the express a web framework for nodejs, another is the React Native from facebook which is a tool for building native mobile applications.

For checking if some of the modules are old and there are newer version we do it using the command, this check the versions from package.json file against the online registry of the package manager

npm outdated

After that we can update all modules but this it's best to do it only when we properly have setup software testing procedures. Also we can make individual updates per package by using their name e.g. for express package

npm update
npm update express

What is Yarn

The first years after npm was created there were many setbacks and bottlenecks like low security, not deterministic installation and slow downloading and installaton speed. The facebook created Yarn as an alternative package manager for nodejs to overcome this kind of problems. The official site is and  the logic is the same for installing and updated software and from package.json, to create one type

yarn init

for installing packages


The last years npm overcome previous problem so npm and yarn are almost the same, so it's matter of preferrence

Installing Tensorflow for machine learning

As we mention previously, package managers can simplify the use and maintenance of external resources like libraries and APIs. Here an example, let's install the javascript library for Tensorflow, it is a ML library, that you can use it in custom web based project, installation is easy with the following command.


yarn add @tensorflow/tfjs


yarn add @tensorflow/tfjs

So now we can easily build and train machine learning models using a purely javacript library directly in any browser. Also there are other versions that of tensorflow if you want run as a backend in server side through nodejs.

Setting up enviroment for ML is easy, now if we to use predifined deep learning models to implement directly data from to aweb application, using keras. A detailed guide to import python keras models in Tensorflow.js there is the official website.