Skip to content

Instantly share code, notes, and snippets.

@farhad0085
Last active June 11, 2026 07:51
Show Gist options
  • Select an option

  • Save farhad0085/13c13ff61236aab04672ec1f8fa366ed to your computer and use it in GitHub Desktop.

Select an option

Save farhad0085/13c13ff61236aab04672ec1f8fa366ed to your computer and use it in GitHub Desktop.
  1. First install nodejs and npm.

    sudo apt-get install nodejs npm
    
  2. Now clean the cache of npm first:

    sudo npm cache clean -f
    
  3. Install n module of npm:

    sudo npm install -g n
    
  4. Begin the installation by selecting the version of node to install: stable or latest or specific version number:

    sudo n stable
    

    or

    sudo n 12.18.2
    

    Current LTS version

    sudo n 16.15.1
    
  5. Check the version of node:

    node -v
    
  6. Check the version of npm:

    npm -v
    

This is going to be beyond the scope of the tutorial. However here is how you could install a specific version if needed:

First, install the required libraries:

sudo apt-get install -y libssl-dev openssl make gcc libbz2-dev libffi-dev liblzma-dev libreadline-dev libncurses5-dev libncursesw5-dev uuid-dev libgdbm-dev libdb5.3-dev tk-dev

Then choose the specific Python from here:

https://www.python.org/ftp/python/

After that go to the /opt directory and download the archive of the specific version:

cd /opt
sudo wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz

Extract the archive:

sudo tar -xf Python-3.12.0.tgz

Then cd into the directory:

cd Python-3.12.0

And finally, compile the new version:

sudo ./configure --enable-optimizations
sudo make
sudo make altinstall

Finally you can create a symlink for that specific Python version so that you could use the binary from anywhere:

sudo ln -fs /opt/Python-3.12.0/Python /usr/bin/python3.12

Then you could check if the python3.12 version is available:

python3.12 --version

Remove python2

sudo apt purge -y python2.7-minimal

Or if you don't sure about python2 version

sudo apt purge -y python2.*

You already have Python3 but don't care about the version

sudo ln -s /usr/bin/python3 /usr/bin/python

Same for pip

sudo apt install -y python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip

Confirm the new version of Python: 3

python --version

Reference: https://stackoverflow.com/a/60590067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment