How To Install node-html2canvas on Ubuntu 18.04
Introduction
In this tutorial we learn how to install node-html2canvas
on Ubuntu 18.04.
What is node-html2canvas
node-html2canvas is:
html2canvas allows you to take “screenshots” of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.
It renders the current page as a canvas image, by reading the DOM and the different styles applied to the elements.
It does not require any rendering from the server, as the whole image is created on the clients browser. However, as it is heavily dependent on the browser, this library is not suitable to be used in nodejs. It doesn’t magically circumvent any browser content policy restrictions either, so rendering cross-origin content will require a proxy to get the content to the same origin.
It is still in a very experimental state, so the author doesn’t recommend using it in a production environment nor start building applications with it yet, as there will be still major changes made.
This package contains the NodeJS package. Note that html2canvas is NOT suited to be used from NodeJS. However some people these days use NPM for non-NodeJS purposes. This package is for those special people.
There are three methods to install node-html2canvas
on Ubuntu 18.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-html2canvas 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-html2canvas
using apt-get
by running the following command:
sudo apt-get -y install node-html2canvas
Install node-html2canvas Using apt
Update apt database with apt
using the following command.
sudo apt update
After updating apt database, We can install node-html2canvas
using apt
by running the following command:
sudo apt -y install node-html2canvas
Install node-html2canvas 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-html2canvas
using aptitude
by running the following command:
sudo aptitude -y install node-html2canvas
How To Uninstall node-html2canvas on Ubuntu 18.04
To uninstall only the node-html2canvas
package we can use the following command:
sudo apt-get remove node-html2canvas
Uninstall node-html2canvas And Its Dependencies
To uninstall node-html2canvas
and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:
sudo apt-get -y autoremove node-html2canvas
Remove node-html2canvas Configurations and Data
To remove node-html2canvas
configuration and data from Ubuntu 18.04 we can use the following command:
sudo apt-get -y purge node-html2canvas
Remove node-html2canvas configuration, data, and all of its dependencies
We can use the following command to remove node-html2canvas
configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge node-html2canvas
References
Summary
In this tutorial we learn how to install node-html2canvas
package on Ubuntu 18.04 using different package management tools: apt
, apt-get
and aptitude
.