How to fix Linux error: Package ‘libjpeg8-dev’ has no installation candidate

Problem:

While trying to install libjpeg8-dev using apt or similar tools, you see the following error message:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package libjpeg8-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libjpeg62-turbo-dev:armhf libjpeg62-turbo-dev

E: Package 'libjpeg8-dev' has no installation candidate

Solution:

As you can see in the error message, the correct package name to install is now libjpeg62-turbo-dev. Therefore, install it using

sudo apt -y install libjpeg62-turbo-dev