How To Install node-nan on Ubuntu 20.04

In this tutorial we learn how to install node-nan on Ubuntu 20.04. node-nan is Native Abstractions for Node.js

Introduction

In this tutorial we learn how to install node-nan on Ubuntu 20.04.

What is node-nan

node-nan is:

A header file filled with macro and utility goodness for making addon development for Node.js easier across versions 0.8, 0.10 and 0.11, and eventually 0.12.

Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.11/0.12, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspec NODE_MODULE_VERSION and get yourself into a macro-tangle.

This project also contains some helper utilities that make addon development a bit more pleasant.

There are three methods to install node-nan on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install node-nan Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install node-nan using apt-get by running the following command:

sudo apt-get -y install node-nan

Install node-nan Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install node-nan using apt by running the following command:

sudo apt -y install node-nan

Install node-nan Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install node-nan using aptitude by running the following command:

sudo aptitude -y install node-nan

How To Uninstall node-nan on Ubuntu 20.04

To uninstall only the node-nan package we can use the following command:

sudo apt-get remove node-nan

Uninstall node-nan And Its Dependencies

To uninstall node-nan and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove node-nan

Remove node-nan Configurations and Data

To remove node-nan configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge node-nan

Remove node-nan configuration, data, and all of its dependencies

We can use the following command to remove node-nan configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge node-nan

References

Summary

In this tutorial we learn how to install node-nan package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.