Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 61f

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox

For a TypeScript training, I needed an environment with Visual Studio Code and Node.js (a JavaScript runtime).

On my Windows laptop, I wanted to create an environment with Ubuntu as guest Operating System, Visual Studio Code and Node.js available within an Oracle VirtualBox appliance.

In my previous article, I shared with you the steps I took, to get this working within an Oracle VirtualBox appliance, by manually installing Ubuntu Desktop.
[https://technology.amis.nl/tech/installing-ubuntu-desktop-22-04-lts-on-a-virtual-machine-using-virtualbox/]

In this article I will describe, as an alternative, installing Ubuntu Desktop with the help of Vagrant, including Visual Studio Code and Node.js. I also will share with you some manual steps I took, to install and try out TypeScript in Visual Studio Code, using the instructions from the TypeScript training.

Visual Studio Code

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes (such as C++, C#, Java, Python, PHP, Go, .NET).
[https://code.visualstudio.com/docs]

Node.js

As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.
[https://nodejs.org/en/]

TypeScript

TypeScript is JavaScript with syntax for types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
[https://www.typescriptlang.org/]

Installing Ubuntu Desktop

First, I search for a Vagrant Box at:

https://app.vagrantup.com/boxes/search

I selected ‘virtualbox’ as provider, and in the search field I typed: Ubuntu 22.04

With the following result:

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 62

Then, I clicked on generic/ubuntu2204 to see some details.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 63

So, I opted for using Vagrant Box: generic/ubuntu2204

First, I created a subdirectory named env on my Windows laptop.

From that directory I opened a Windows Command Prompt (cmd) and typed:

vagrant init generic/ubuntu2204

This initializes the current directory to be a Vagrant environment by creating an initial Vagrantfile if one does not already exist.
[https://www.vagrantup.com/docs/cli/init.html]

With the following output:

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

This created an example Vagrantfile in the env directory, with the following content:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "generic/ubuntu2204"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

For simplicity, I changed the content of the Vagrantfile (in line with what I described in my other articles about Vagrant) to:

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_nodejs" do |ubuntu_vsc_nodejs|
      
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code and Node.js"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    end
    
  end

end

To install the needed software, I added to the env directory a subdirectory called scripts.

In the scripts directory I created a file ubuntu_etc.sh with the following content:

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

echo "**** End installing Ubuntu, etc"

Actually, this script doesn’t do anything at the moment.

I used the following command on the Windows Command Prompt: vagrant up

This command creates and configures guest machines according to your Vagrantfile.
[https://www.vagrantup.com/docs/cli/up.html]

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_nodejs' up with 'virtualbox' provider...
==> ubuntu_vsc_nodejs: Importing base box 'generic/ubuntu2204'...
==> ubuntu_vsc_nodejs: Matching MAC address for NAT networking...
==> ubuntu_vsc_nodejs: Checking if box 'generic/ubuntu2204' version '4.1.4' is up to date...
==> ubuntu_vsc_nodejs: Setting the name of the VM: Ubuntu Desktop, Visual Studio Code and Node.js
==> ubuntu_vsc_nodejs: Clearing any previously set network interfaces...
==> ubuntu_vsc_nodejs: Preparing network interfaces based on configuration...
    ubuntu_vsc_nodejs: Adapter 1: nat
==> ubuntu_vsc_nodejs: Forwarding ports...
    ubuntu_vsc_nodejs: 22 (guest) => 2222 (host) (adapter 1)
==> ubuntu_vsc_nodejs: Running 'pre-boot' VM customizations...
==> ubuntu_vsc_nodejs: Booting VM...
==> ubuntu_vsc_nodejs: Waiting for machine to boot. This may take a few minutes...
    ubuntu_vsc_nodejs: SSH address: 127.0.0.1:2222
    ubuntu_vsc_nodejs: SSH username: vagrant
    ubuntu_vsc_nodejs: SSH auth method: private key
                                                                         
    ubuntu_vsc_nodejs: Warning: Connection reset. Retrying...
    ubuntu_vsc_nodejs: Warning: Connection aborted. Retrying...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Vagrant insecure key detected. Vagrant will automatically replace
    ubuntu_vsc_nodejs: this with a newly generated keypair for better security.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Inserting generated public key within guest...
    ubuntu_vsc_nodejs: Removing insecure key from the guest if it's present...
    ubuntu_vsc_nodejs: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ubuntu_vsc_nodejs: Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.34
Going on, assuming VBoxService is correct...
[ubuntu_vsc_nodejs] A Virtualbox Guest Additions installation was found but no tools to rebuild or start them.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.34
Going on, assuming VBoxService is correct...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package virtualbox-guest-dkms
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-5.15.0-41-generic is already the newest version (5.15.0-41.44).
linux-headers-5.15.0-41-generic set to manually installed.
The following additional packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
Suggested packages:
  bzip2-doc cpp-doc gcc-11-locales debtags menu debian-keyring g++-multilib
  g++-11-multilib gcc-11-doc gcc-multilib autoconf automake libtool flex bison
  gdb gcc-doc gcc-11-multilib glibc-doc bzr libgd-tools libstdc++-11-doc
  make-doc
The following NEW packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dkms dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Need to get 63.7 MB of archives.
After this operation, 207 MB of additional disk space will be used.
Get:1 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 gcc-11-base amd64 11.2.0-19ubuntu1 [20.8 kB]
...
Get:54 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 manpages-dev all 5.10-1ubuntu1 [2,309 kB]
Err:24 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-41.44
  404  Not Found [IP: 147.75.80.249 443]
Fetched 62.4 MB in 11s (5,845 kB/s)
E: Failed to fetch https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux/linux-libc-dev_5.15.0-41.44_amd64.deb  404  Not Found [IP: 147.75.80.249 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
                                                                             
...
Get:29 https://mirrors.edge.kernel.org/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [228 B]
Fetched 2,193 kB in 1s (2,092 kB/s)
Reading package lists...
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-5.15.0-41-generic is already the newest version (5.15.0-41.44).
linux-headers-5.15.0-41-generic set to manually installed.
The following additional packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6 libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-common libtirpc-dev libtirpc3 libtsan0
  libubsan1 libwebp7 libxpm4 linux-libc-dev lto-disabled-list make
  manpages-dev rpcsvc-proto
Suggested packages:
  bzip2-doc cpp-doc gcc-11-locales debtags menu debian-keyring g++-multilib
  g++-11-multilib gcc-11-doc gcc-multilib autoconf automake libtool flex bison
  gdb gcc-doc gcc-11-multilib glibc-doc bzr libgd-tools libstdc++-11-doc
  make-doc
Recommended packages:
  libnss-nis libnss-nisplus
The following NEW packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dkms dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
The following packages will be upgraded:
  libc6 libtirpc-common libtirpc3
3 upgraded, 54 newly installed, 0 to remove and 18 not upgraded.
Need to get 6,964 kB/67.1 MB of archives.
After this operation, 207 MB of additional disk space will be used.
Get:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc6 amd64 2.35-0ubuntu3.1 [3,235 kB]
Get:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc-dev-bin amd64 2.35-0ubuntu3.1 [20.4 kB]
Get:3 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-43.46 [1,298 kB]
Get:4 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc-common all 1.3.2-2ubuntu0.1 [7,766 B]
Get:5 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc3 amd64 1.3.2-2ubuntu0.1 [82.3 kB]
Get:6 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc-dev amd64 1.3.2-2ubuntu0.1 [192 kB]
Get:7 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc6-dev amd64 2.35-0ubuntu3.1 [2,099 kB]
Get:8 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc-devtools amd64 2.35-0ubuntu3.1 [28.9 kB]
Preconfiguring packages ...
Fetched 6,964 kB in 2s (4,568 kB/s)
Selecting previously unselected package gcc-11-base:amd64.
(Reading database ... 75172 files and directories currently installed.)
...
Copy iso file C:\My\App\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
Installing Virtualbox Guest Additions 6.1.36 - guest version is 6.1.34
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.36 Guest Additions for Linux........
VirtualBox Guest Additions installer
VBoxControl: error: Could not contact the host system.  Make sure that you are running this
VBoxControl: error: application inside a VirtualBox guest system, and that you have sufficient
VBoxControl: error: user permissions.
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-41-generic': No such file or directory
Copying additional installer modules ...
Installing additional modules ...
/opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
/opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-41-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-41-generic
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> ubuntu_vsc_nodejs: Checking for guest additions in VM...
==> ubuntu_vsc_nodejs: Running provisioner: ubuntu_etc shell script (shell)...
    ubuntu_vsc_nodejs: Running: C:/Users/marc_l/AppData/Local/Temp/vagrant-shell20220804-14752-6p3f5e.sh
    ubuntu_vsc_nodejs: **** Begin installing Ubuntu, etc
 
    ubuntu_vsc_nodejs: **** End installing Ubuntu, etc

By the way, importing this base box and creating the virtual machine takes quite some time!

Because in the VagrantfiIe, I choose to display the VirtualBox GUI when booting the machine (vb.gui = true), at the end this GUI was visible.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 64

I closed this window by selecting ‘Power off the machine’ (via the menu: File | Close | Power off the machine).

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 65

In the Oracle VM VirtualBox Manager window, I could see the VirtualBox with the name ‘Ubuntu Desktop, Visual Studio Code and Node.js’ was created.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 66

Changing the ‘Display’ settings

I had a look at the settings and noticed the Display | Graphics Controller was set to ‘VBoxSVGA’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 67

I selected ‘Settings’. Then navigated to the Display tab.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 68

I wanted to use the same ‘Display’ settings when manually installing Ubuntu Desktop (as I described in my previous article) and also get rid of the warning at the bottom of the window.
[https://technology.amis.nl/tech/installing-ubuntu-desktop-22-04-lts-on-a-virtual-machine-using-virtualbox/]

If you remember from my previous article, these are the recommended system requirements for Ubuntu 22.04 LTS:

  • 2 GHz dual-core processor or better
  • 4 GB system memory
  • 25 GB of free hard drive space
  • Internet access is helpful
  • Either a DVD drive or a USB port for the installer media

[https://technology.amis.nl/tech/installing-ubuntu-desktop-22-04-lts-on-a-virtual-machine-using-virtualbox/]

Therefore, I changed the content of Vagrantfile to:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_nodejs" do |ubuntu_vsc_nodejs|
      
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code and Node.js"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    end
    
  end

end

Vagrant VirtualBox provider configuration:

The VirtualBox provider exposes some additional configuration options that allow you to more finely control your VirtualBox-powered Vagrant environments.
[https://www.vagrantup.com/docs/providers/virtualbox/configuration ]

VBoxManage Customizations:

VBoxManage is a utility that can be used to make modifications to VirtualBox virtual machines from the command line.

Vagrant exposes a way to call any command against VBoxManage just prior to booting the machine.
[https://www.vagrantup.com/docs/providers/virtualbox/configuration ]

For example:

vb.customize [‘modifyvm’, :id, ‘–vram’, ’16’]

There are some convenience shortcuts for memory and CPU settings:
[https://www.vagrantup.com/docs/providers/virtualbox/configuration ]

vb.memory = “4096”
vb.cpus = “2”

In order to stop the running machine and destroy its resources, use the following command on the Windows Command Prompt: vagrant destroy

With the following output:

    ubuntu_vsc_nodejs: Are you sure you want to destroy the 'ubuntu_vsc_nodejs' VM? [y/N] y
==> ubuntu_vsc_nodejs: Discarding saved state of VM...
==> ubuntu_vsc_nodejs: Destroying VM and associated drives...

This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.
[https://www.vagrantup.com/docs/cli/destroy.html]

From here on in this blog, for simplicity, I will no longer mention the vagrant destroy command preceding the vagrant up command.

I used the following command on the Windows Command Prompt: vagrant up

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_nodejs' up with 'virtualbox' provider...
==> ubuntu_vsc_nodejs: Importing base box 'generic/ubuntu2204'...
==> ubuntu_vsc_nodejs: Matching MAC address for NAT networking...
==> ubuntu_vsc_nodejs: Checking if box 'generic/ubuntu2204' version '4.1.4' is up to date...
==> ubuntu_vsc_nodejs: Setting the name of the VM: Ubuntu Desktop, Visual Studio Code and Node.js
==> ubuntu_vsc_nodejs: Clearing any previously set network interfaces...
==> ubuntu_vsc_nodejs: Preparing network interfaces based on configuration...
    ubuntu_vsc_nodejs: Adapter 1: nat
==> ubuntu_vsc_nodejs: Forwarding ports...
    ubuntu_vsc_nodejs: 22 (guest) => 2222 (host) (adapter 1)
==> ubuntu_vsc_nodejs: Running 'pre-boot' VM customizations...
==> ubuntu_vsc_nodejs: Booting VM...
==> ubuntu_vsc_nodejs: Waiting for machine to boot. This may take a few minutes...
    ubuntu_vsc_nodejs: SSH address: 127.0.0.1:2222
    ubuntu_vsc_nodejs: SSH username: vagrant
    ubuntu_vsc_nodejs: SSH auth method: private key
    ubuntu_vsc_nodejs: Warning: Remote connection disconnect. Retrying...
    ubuntu_vsc_nodejs: Warning: Connection reset. Retrying...
    ubuntu_vsc_nodejs: Warning: Connection aborted. Retrying...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Vagrant insecure key detected. Vagrant will automatically replace
    ubuntu_vsc_nodejs: this with a newly generated keypair for better security.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Inserting generated public key within guest...
    ubuntu_vsc_nodejs: Removing insecure key from the guest if it's present...
    ubuntu_vsc_nodejs: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ubuntu_vsc_nodejs: Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.34
Going on, assuming VBoxService is correct...
[ubuntu_vsc_nodejs] A Virtualbox Guest Additions installation was found but no tools to rebuild or start them.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.34
Going on, assuming VBoxService is correct...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package virtualbox-guest-dkms
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-5.15.0-41-generic is already the newest version (5.15.0-41.44).
linux-headers-5.15.0-41-generic set to manually installed.
The following additional packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
Suggested packages:
  bzip2-doc cpp-doc gcc-11-locales debtags menu debian-keyring g++-multilib
  g++-11-multilib gcc-11-doc gcc-multilib autoconf automake libtool flex bison
  gdb gcc-doc gcc-11-multilib glibc-doc bzr libgd-tools libstdc++-11-doc
  make-doc
The following NEW packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dkms dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
0 upgraded, 54 newly installed, 0 to remove and 4 not upgraded.
Need to get 63.7 MB of archives.
After this operation, 207 MB of additional disk space will be used.
Get:1 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 gcc-11-base amd64 11.2.0-19ubuntu1 [20.8 kB]
...
Get:54 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 manpages-dev all 5.10-1ubuntu1 [2,309 kB]
Err:24 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-41.44
  404  Not Found [IP: 147.75.80.249 443]
Fetched 62.4 MB in 41s (1,532 kB/s)
E: Failed to fetch https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux/linux-libc-dev_5.15.0-41.44_amd64.deb  404  Not Found [IP: 147.75.80.249 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Get:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease [114 kB]
...
Get:29 https://mirrors.edge.kernel.org/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [228 B]
Fetched 2,193 kB in 2s (1,364 kB/s)
Reading package lists...
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-5.15.0-41-generic is already the newest version (5.15.0-41.44).
linux-headers-5.15.0-41-generic set to manually installed.
The following additional packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6 libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-common libtirpc-dev libtirpc3 libtsan0
  libubsan1 libwebp7 libxpm4 linux-libc-dev lto-disabled-list make
  manpages-dev rpcsvc-proto
Suggested packages:
  bzip2-doc cpp-doc gcc-11-locales debtags menu debian-keyring g++-multilib
  g++-11-multilib gcc-11-doc gcc-multilib autoconf automake libtool flex bison
  gdb gcc-doc gcc-11-multilib glibc-doc bzr libgd-tools libstdc++-11-doc
  make-doc
Recommended packages:
  libnss-nis libnss-nisplus
The following NEW packages will be installed:
  build-essential bzip2 cpp cpp-11 dctrl-tools dkms dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgd3 libgomp1 libisl23 libitm1 libjbig0
  libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libxpm4
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
The following packages will be upgraded:
  libc6 libtirpc-common libtirpc3
3 upgraded, 54 newly installed, 0 to remove and 18 not upgraded.
Need to get 6,964 kB/67.1 MB of archives.
After this operation, 207 MB of additional disk space will be used.
Get:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc6 amd64 2.35-0ubuntu3.1 [3,235 kB]
Get:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc-dev-bin amd64 2.35-0ubuntu3.1 [20.4 kB]
Get:3 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-43.46 [1,298 kB]
Get:4 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc-common all 1.3.2-2ubuntu0.1 [7,766 B]
Get:5 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc3 amd64 1.3.2-2ubuntu0.1 [82.3 kB]
Get:6 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libtirpc-dev amd64 1.3.2-2ubuntu0.1 [192 kB]
Get:7 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc6-dev amd64 2.35-0ubuntu3.1 [2,099 kB]
Get:8 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 libc-devtools amd64 2.35-0ubuntu3.1 [28.9 kB]
Preconfiguring packages ...
Fetched 6,964 kB in 4s (1,784 kB/s)
Selecting previously unselected package gcc-11-base:amd64.
(Reading database ... 75172 files and directories currently installed.)
...
Copy iso file C:\My\App\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
Installing Virtualbox Guest Additions 6.1.36 - guest version is 6.1.34
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.36 Guest Additions for Linux........
VirtualBox Guest Additions installer
VBoxControl: error: Could not contact the host system.  Make sure that you are running this
VBoxControl: error: application inside a VirtualBox guest system, and that you have sufficient
VBoxControl: error: user permissions.
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-41-generic': No such file or directory
Copying additional installer modules ...
Installing additional modules ...
/opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
/opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-41-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-41-generic
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> ubuntu_vsc_nodejs: Checking for guest additions in VM...
==> ubuntu_vsc_nodejs: Running provisioner: ubuntu_etc shell script (shell)...
    ubuntu_vsc_nodejs: Running: C:/Users/marc_l/AppData/Local/Temp/vagrant-shell20220804-14752-6p3f5e.sh
    ubuntu_vsc_nodejs: **** Begin installing Ubuntu, etc
    ubuntu_vsc_nodejs: **** End installing Ubuntu, etc

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 69

Again, in the Oracle VM VirtualBox Manager window, I had a look at the ‘Display’ settings and now the Graphics Controller was set to ‘VMSVGA’.

Install the Desktop Components (GUI) on an Ubuntu Server

In order to install a GUI, I changed the content of my ubuntu_etc.sh script to:
[in bold, I highlighted the changes]

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

sudo apt update
sudo apt upgrade -y
echo "**** Begin installing ubuntu-desktop"
sudo apt install ubuntu-desktop -y
echo "**** End installing ubuntu-desktop"

echo "**** End installing Ubuntu, etc"

Remark about apt update:
update is used to download package information from all configured sources. Other commands operate on this data to e.g. perform package upgrades or search in and display details about all packages available for installation.
[https://manpages.ubuntu.com/manpages/jammy/man8/apt.8.html]

Remark about apt upgrade:
upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via sources.list. New packages will be installed if required to satisfy dependencies, but existing packages will never be removed. If an upgrade for a package requires the removal of an installed package the upgrade for this package isn’t performed.
[https://manpages.ubuntu.com/manpages/jammy/man8/apt.8.html]

-y, –yes, –assume-yes
Automatic yes to prompts; assume “yes” as answer to all prompts and run non-interactively.
[https://manpages.ubuntu.com/manpages/jammy/man8/apt-get.8.html]

I used the following command on the Windows Command Prompt: vagrant up

With the following output (only showing the relevant parts):

    ubuntu_vsc_nodejs: **** Begin installing Ubuntu, etc
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_nodejs: Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
    ubuntu_vsc_nodejs: Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
    ubuntu_vsc_nodejs: Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: 18 packages can be upgraded. Run 'apt list --upgradable' to see them.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: Calculating upgrade...
    ubuntu_vsc_nodejs: The following NEW packages will be installed:
    ubuntu_vsc_nodejs:   linux-cloud-tools-5.15.0-43 linux-cloud-tools-5.15.0-43-generic
    ubuntu_vsc_nodejs:   linux-headers-5.15.0-43 linux-headers-5.15.0-43-generic
    ubuntu_vsc_nodejs:   linux-image-5.15.0-43-generic linux-modules-5.15.0-43-generic
    ubuntu_vsc_nodejs:   linux-modules-extra-5.15.0-43-generic
    ubuntu_vsc_nodejs: The following packages will be upgraded:
    ubuntu_vsc_nodejs:   apt apt-utils base-files libapt-pkg6.0 libc-bin libgstreamer1.0-0
    ubuntu_vsc_nodejs:   libnetplan0 linux-cloud-tools-common linux-cloud-tools-virtual linux-generic
    ubuntu_vsc_nodejs:   linux-headers-generic linux-image-generic locales motd-news-config
    ubuntu_vsc_nodejs:   netplan.io python-apt-common python3-apt python3-gi
    ubuntu_vsc_nodejs: 18 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs: 5 standard security updates
    ubuntu_vsc_nodejs: Need to get 119 MB of archives.
    ubuntu_vsc_nodejs: After this operation, 562 MB of additional disk space will be used.
    ubuntu_vsc_nodejs: Get:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 motd-news-config all 12ubuntu4.2 [4,612 B]
...
    ubuntu_vsc_nodejs: Get:25 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 linux-headers-generic amd64 5.15.0.43.44 [2,438 B]
    ubuntu_vsc_nodejs: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_nodejs: Fetched 119 MB in 60s (1,984 kB/s)
(Reading database ... 80989 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../motd-news-config_12ubuntu4.2_all.deb ...
    ubuntu_vsc_nodejs: Unpacking motd-news-config (12ubuntu4.2) over (12ubuntu4.1) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../base-files_12ubuntu4.2_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking base-files (12ubuntu4.2) over (12ubuntu4.1) ...
    ubuntu_vsc_nodejs: Setting up base-files (12ubuntu4.2) ...
    ubuntu_vsc_nodejs: Installing new version of config file /etc/issue ...
    ubuntu_vsc_nodejs: Installing new version of config file /etc/issue.net ...
    ubuntu_vsc_nodejs: Installing new version of config file /etc/lsb-release ...
    ubuntu_vsc_nodejs: motd-news.timer is a disabled or a static unit not running, not starting it.
    ubuntu_vsc_nodejs: motd-news.service is a disabled or a static unit not running, not starting it.
(Reading database ... 80989 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../libc-bin_2.35-0ubuntu3.1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking libc-bin (2.35-0ubuntu3.1) over (2.35-0ubuntu3) ...
    ubuntu_vsc_nodejs: Setting up libc-bin (2.35-0ubuntu3.1) ...
(Reading database ... 80989 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../libapt-pkg6.0_2.4.6_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking libapt-pkg6.0:amd64 (2.4.6) over (2.4.5) ...
    ubuntu_vsc_nodejs: Setting up libapt-pkg6.0:amd64 (2.4.6) ...
(Reading database ... 80989 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../archives/apt_2.4.6_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking apt (2.4.6) over (2.4.5) ...
    ubuntu_vsc_nodejs: Setting up apt (2.4.6) ...
    ubuntu_vsc_nodejs: apt-daily-upgrade.timer is a disabled or a static unit not running, not starting it.
    ubuntu_vsc_nodejs: apt-daily.timer is a disabled or a static unit not running, not starting it.
(Reading database ... 80989 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../00-apt-utils_2.4.6_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking apt-utils (2.4.6) over (2.4.5) ...    ubuntu_vsc_nodejs: Preparing to unpack .../01-netplan.io_0.104-0ubuntu2.1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking netplan.io (0.104-0ubuntu2.1) over (0.104-0ubuntu2) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../02-libnetplan0_0.104-0ubuntu2.1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking libnetplan0:amd64 (0.104-0ubuntu2.1) over (0.104-0ubuntu2) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../03-locales_2.35-0ubuntu3.1_all.deb ...
    ubuntu_vsc_nodejs: Unpacking locales (2.35-0ubuntu3.1) over (2.35-0ubuntu3) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../04-python-apt-common_2.3.0ubuntu2.1_all.deb ...
    ubuntu_vsc_nodejs: Unpacking python-apt-common (2.3.0ubuntu2.1) over (2.3.0ubuntu2) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../05-python3-apt_2.3.0ubuntu2.1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking python3-apt (2.3.0ubuntu2.1) over (2.3.0ubuntu2) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../06-python3-gi_3.42.1-0ubuntu1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking python3-gi (3.42.1-0ubuntu1) over (3.42.0-3build1) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../07-libgstreamer1.0-0_1.20.3-0ubuntu1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking libgstreamer1.0-0:amd64 (1.20.3-0ubuntu1) over (1.20.1-1) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../08-linux-cloud-tools-common_5.15.0-43.46_all.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-cloud-tools-common (5.15.0-43.46) over (5.15.0-41.44) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-cloud-tools-5.15.0-43.
    ubuntu_vsc_nodejs: Preparing to unpack .../09-linux-cloud-tools-5.15.0-43_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-cloud-tools-5.15.0-43 (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-cloud-tools-5.15.0-43-generic.
    ubuntu_vsc_nodejs: Preparing to unpack .../10-linux-cloud-tools-5.15.0-43-generic_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-cloud-tools-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../11-linux-cloud-tools-virtual_5.15.0.43.44_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-cloud-tools-virtual (5.15.0.43.44) over (5.15.0.41.43) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-modules-5.15.0-43-generic.
    ubuntu_vsc_nodejs: Preparing to unpack .../12-linux-modules-5.15.0-43-generic_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-modules-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-image-5.15.0-43-generic.
    ubuntu_vsc_nodejs: Preparing to unpack .../13-linux-image-5.15.0-43-generic_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-image-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-modules-extra-5.15.0-43-generic.
    ubuntu_vsc_nodejs: Preparing to unpack .../14-linux-modules-extra-5.15.0-43-generic_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-modules-extra-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../15-linux-generic_5.15.0.43.44_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-generic (5.15.0.43.44) over (5.15.0.41.43) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../16-linux-image-generic_5.15.0.43.44_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-image-generic (5.15.0.43.44) over (5.15.0.41.43) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-headers-5.15.0-43.
    ubuntu_vsc_nodejs: Preparing to unpack .../17-linux-headers-5.15.0-43_5.15.0-43.46_all.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-headers-5.15.0-43 (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Selecting previously unselected package linux-headers-5.15.0-43-generic.
    ubuntu_vsc_nodejs: Preparing to unpack .../18-linux-headers-5.15.0-43-generic_5.15.0-43.46_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-headers-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Preparing to unpack .../19-linux-headers-generic_5.15.0.43.44_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking linux-headers-generic (5.15.0.43.44) over (5.15.0.41.43) ...
    ubuntu_vsc_nodejs: Setting up motd-news-config (12ubuntu4.2) ...
    ubuntu_vsc_nodejs: Setting up apt-utils (2.4.6) ...
    ubuntu_vsc_nodejs: Setting up libnetplan0:amd64 (0.104-0ubuntu2.1) ...
    ubuntu_vsc_nodejs: Setting up linux-cloud-tools-common (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: hv-kvp-daemon.service is a disabled or a static unit not running, not starting it.
    ubuntu_vsc_nodejs: Setting up locales (2.35-0ubuntu3.1) ...
    ubuntu_vsc_nodejs: Generating locales (this might take a while)...
    ubuntu_vsc_nodejs:   en_US.UTF-8... done
    ubuntu_vsc_nodejs: Generation complete.
    ubuntu_vsc_nodejs: Setting up netplan.io (0.104-0ubuntu2.1) ...    ubuntu_vsc_nodejs: Setting up linux-headers-5.15.0-43 (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Setting up python3-gi (3.42.1-0ubuntu1) ...
    ubuntu_vsc_nodejs: Setting up linux-cloud-tools-5.15.0-43 (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Setting up linux-cloud-tools-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Setting up python-apt-common (2.3.0ubuntu2.1) ...
    ubuntu_vsc_nodejs: Setting up libgstreamer1.0-0:amd64 (1.20.3-0ubuntu1) ...
    ubuntu_vsc_nodejs: Setcap worked! gst-ptp-helper is not suid!
    ubuntu_vsc_nodejs: Setting up python3-apt (2.3.0ubuntu2.1) ...
    ubuntu_vsc_nodejs: Setting up linux-headers-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: /etc/kernel/header_postinst.d/dkms:
    ubuntu_vsc_nodejs:  * dkms: running auto installation service for kernel 5.15.0-43-generic
    ubuntu_vsc_nodejs:    ...done.
    ubuntu_vsc_nodejs: Setting up linux-cloud-tools-virtual (5.15.0.43.44) ...
    ubuntu_vsc_nodejs: Setting up linux-headers-generic (5.15.0.43.44) ...
    ubuntu_vsc_nodejs: Setting up linux-modules-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Setting up linux-image-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: I: /boot/vmlinuz is now a symlink to vmlinuz-5.15.0-43-generic
    ubuntu_vsc_nodejs: I: /boot/initrd.img is now a symlink to initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs: Setting up linux-modules-extra-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: Setting up linux-image-generic (5.15.0.43.44) ...
    ubuntu_vsc_nodejs: Setting up linux-generic (5.15.0.43.44) ...
    ubuntu_vsc_nodejs: Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    ubuntu_vsc_nodejs: Processing triggers for man-db (2.10.2-1) ...
    ubuntu_vsc_nodejs: Processing triggers for plymouth-theme-ubuntu-text (0.9.5+git20211018-1ubuntu3) ...
    ubuntu_vsc_nodejs: update-initramfs: deferring update (trigger activated)
    ubuntu_vsc_nodejs: Processing triggers for dbus (1.12.20-2ubuntu4) ...
    ubuntu_vsc_nodejs: Processing triggers for install-info (6.8-4build1) ...
    ubuntu_vsc_nodejs: Processing triggers for linux-image-5.15.0-43-generic (5.15.0-43.46) ...
    ubuntu_vsc_nodejs: /etc/kernel/postinst.d/dkms:
    ubuntu_vsc_nodejs:  * dkms: running auto installation service for kernel 5.15.0-43-generic
    ubuntu_vsc_nodejs:    ...done.
    ubuntu_vsc_nodejs: /etc/kernel/postinst.d/initramfs-tools:
    ubuntu_vsc_nodejs: update-initramfs: Generating /boot/initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs: /etc/kernel/postinst.d/vboxadd:
    ubuntu_vsc_nodejs: /opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
    ubuntu_vsc_nodejs: /opt/VBoxGuestAdditions-6.1.36/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
    ubuntu_vsc_nodejs: VirtualBox Guest Additions: Building the modules for kernel 5.15.0-43-generic.
    ubuntu_vsc_nodejs: update-initramfs: Generating /boot/initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs: /etc/kernel/postinst.d/zz-update-grub:
    ubuntu_vsc_nodejs: Sourcing file `/etc/default/grub'
    ubuntu_vsc_nodejs: Sourcing file `/etc/default/grub.d/init-select.cfg'
    ubuntu_vsc_nodejs: Generating grub configuration file ...
    ubuntu_vsc_nodejs: Found linux image: /boot/vmlinuz-5.15.0-43-generic
    ubuntu_vsc_nodejs: Found initrd image: /boot/initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs: Found linux image: /boot/vmlinuz-5.15.0-41-generic
    ubuntu_vsc_nodejs: Found initrd image: /boot/initrd.img-5.15.0-41-generic
    ubuntu_vsc_nodejs: Warning: os-prober will not be executed to detect other bootable partitions.
    ubuntu_vsc_nodejs: Systems on them will not be added to the GRUB boot configuration.
    ubuntu_vsc_nodejs: Check GRUB_DISABLE_OS_PROBER documentation entry.
    ubuntu_vsc_nodejs: done
    ubuntu_vsc_nodejs: Processing triggers for initramfs-tools (0.140ubuntu13) ...
    ubuntu_vsc_nodejs: update-initramfs: Generating /boot/initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Pending kernel upgrade!
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Running kernel version:
    ubuntu_vsc_nodejs:   5.15.0-41-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Diagnostics:
    ubuntu_vsc_nodejs:   The currently running kernel version is not the expected kernel version 5.15.0-43-generic.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Services to be restarted:
    ubuntu_vsc_nodejs:  systemctl restart cron.service
    ubuntu_vsc_nodejs:  systemctl restart haveged.service
    ubuntu_vsc_nodejs:  systemctl restart ifplugd.service
    ubuntu_vsc_nodejs:  systemctl restart irqbalance.service
    ubuntu_vsc_nodejs:  systemctl restart multipathd.service
    ubuntu_vsc_nodejs:  systemctl restart packagekit.service
    ubuntu_vsc_nodejs:  systemctl restart polkit.service
    ubuntu_vsc_nodejs:  systemctl restart rsyslog.service
    ubuntu_vsc_nodejs:  systemctl restart snapd.service
    ubuntu_vsc_nodejs:  systemctl restart ssh.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-journald.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-networkd.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-resolved.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-udevd.service
    ubuntu_vsc_nodejs:  systemctl restart udisks2.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Service restarts being deferred:
    ubuntu_vsc_nodejs:  systemctl restart ModemManager.service
    ubuntu_vsc_nodejs:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_nodejs:  systemctl restart getty@tty1.service
    ubuntu_vsc_nodejs:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-logind.service
    ubuntu_vsc_nodejs:  systemctl restart user@1000.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No containers need to be restarted.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No user sessions are running outdated binaries.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_nodejs: **** Begin installing ubuntu-desktop
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: The following additional packages will be installed:
    ubuntu_vsc_nodejs:   accountsservice acl acpi-support acpid adwaita-icon-theme aisleriot
...
    ubuntu_vsc_nodejs:   yelp-xsl zenity zenity-common
    ubuntu_vsc_nodejs: The following packages will be upgraded:
    ubuntu_vsc_nodejs:   python3-distupgrade ubuntu-release-upgrader-core
    ubuntu_vsc_nodejs: 2 upgraded, 1111 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs: Need to get 630 MB of archives.
    ubuntu_vsc_nodejs: After this operation, 2,155 MB of additional disk space will be used.
    ubuntu_vsc_nodejs: Get:1 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 acpid amd64 1:2.0.33-1ubuntu1 [35.8 kB]
...
    ubuntu_vsc_nodejs: Get:1113 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 xserver-xorg-legacy amd64 2:21.1.3-2ubuntu2.1 [34.4 kB]
    ubuntu_vsc_nodejs: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_nodejs: Fetched 630 MB in 5min 44s (1,831 kB/s)
    ubuntu_vsc_nodejs: Selecting previously unselected package acpid.
(Reading database ... 116483 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../0000-acpid_1%3a2.0.33-1ubuntu1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking acpid (1:2.0.33-1ubuntu1) ...
...
    ubuntu_vsc_nodejs: Creating config file /etc/gdm3/greeter.dconf-defaults with new version
    ubuntu_vsc_nodejs: update-alternatives: using /etc/pam.d/gdm-smartcard-sssd-exclusive to provide /etc/pam.d/gdm-smartcard (gdm-smartcard) in auto mode
    ubuntu_vsc_nodejs: Setting up gnome-todo (3.28.1-6ubuntu1) ...
    ubuntu_vsc_nodejs: Setting up update-notifier (3.192.54) ...
    ubuntu_vsc_nodejs: Setting up gnome-shell-extension-desktop-icons-ng (43-2ubuntu1) ...
    ubuntu_vsc_nodejs: Setting up network-manager-gnome (1.24.0-1ubuntu3) ...
    ubuntu_vsc_nodejs: Setting up update-manager (1:22.04.9) ...
    ubuntu_vsc_nodejs: Setting up gnome-shell-extension-ubuntu-dock (72~ubuntu5.22.04.1) ...
    ubuntu_vsc_nodejs: Setting up ubuntu-desktop-minimal (1.481) ...
    ubuntu_vsc_nodejs: Setting up ubuntu-desktop (1.481) ...
    ubuntu_vsc_nodejs: Processing triggers for sgml-base (1.30) ...
    ubuntu_vsc_nodejs: Setting up sgml-data (2.0.11+nmu1) ...
    ubuntu_vsc_nodejs: Processing triggers for sgml-base (1.30) ...
    ubuntu_vsc_nodejs: Setting up docbook-xml (4.5-11) ...
    ubuntu_vsc_nodejs: Processing triggers for dictionaries-common (1.28.14) ...
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-common].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-variant_0].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-variant_1].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-variant_2].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en-wo_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_AU-variant_0].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_AU-variant_1].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_AU-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_AU-wo_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_CA-variant_0].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_CA-variant_1].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_CA-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_CA-wo_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-ise-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-ise-wo_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-ize-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-ize-wo_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-variant_0].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_GB-variant_1].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_US-w_accents-only].
    ubuntu_vsc_nodejs: aspell-autobuildhash: processing: en [en_US-wo_accents-only].
    ubuntu_vsc_nodejs: Processing triggers for initramfs-tools (0.140ubuntu13) ...
    ubuntu_vsc_nodejs: update-initramfs: Generating /boot/initrd.img-5.15.0-43-generic
    ubuntu_vsc_nodejs: Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.8+dfsg-1) ...
    ubuntu_vsc_nodejs: Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    ubuntu_vsc_nodejs: Processing triggers for dbus (1.12.20-2ubuntu4) ...
    ubuntu_vsc_nodejs: Processing triggers for ufw (0.36.1-4build1) ...
    ubuntu_vsc_nodejs: Processing triggers for rygel (0.40.3-1ubuntu2) ...
    ubuntu_vsc_nodejs: Processing triggers for sgml-base (1.30) ...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Pending kernel upgrade!
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Running kernel version:
    ubuntu_vsc_nodejs:   5.15.0-41-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Diagnostics:
    ubuntu_vsc_nodejs:   The currently running kernel version is not the expected kernel version 5.15.0-43-generic.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Services to be restarted:
    ubuntu_vsc_nodejs:  systemctl restart cron.service
    ubuntu_vsc_nodejs:  systemctl restart haveged.service
    ubuntu_vsc_nodejs:  systemctl restart ifplugd.service
    ubuntu_vsc_nodejs:  systemctl restart irqbalance.service
    ubuntu_vsc_nodejs:  systemctl restart multipathd.service
    ubuntu_vsc_nodejs:  systemctl restart packagekit.service
    ubuntu_vsc_nodejs:  systemctl restart polkit.service
    ubuntu_vsc_nodejs:  systemctl restart rsyslog.service
    ubuntu_vsc_nodejs:  systemctl restart ssh.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-journald.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-networkd.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-resolved.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-udevd.service
    ubuntu_vsc_nodejs:  systemctl restart udisks2.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Service restarts being deferred:
    ubuntu_vsc_nodejs:  systemctl restart ModemManager.service
    ubuntu_vsc_nodejs:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_nodejs:  systemctl restart getty@tty1.service
    ubuntu_vsc_nodejs:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-logind.service
    ubuntu_vsc_nodejs:  systemctl restart user@1000.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No containers need to be restarted.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No user sessions are running outdated binaries.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_nodejs: **** End installing ubuntu-desktop
    ubuntu_vsc_nodejs: **** End installing Ubuntu, etc

Form the output, you can see that VirtualBox Guest Additions were also installed.

In the VirtualBox GUI, I logged in as user: vagrant

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 70

I used the following command on the VirtualBox GUI shell: sudo reboot
After a while, the login screen appeared.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 71

After I logged in, I had to step through some welcome screens.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 72

Since the VirtualBox Guest Additions were already installed, from the VirtualBox menu, I first selected View | Auto-resize Guest Display.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 73

This nicely resized the display.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 74

Then, I stepped through the welcome screens.
I mostly used the ‘Next’ button.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 75

I clicked on the ‘Next’ button, skipping the set up of Livepatch.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 76

Here, I chose not to send system info.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 77

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 78

Finally, I clicked on the ‘Done’ button.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 79

A few more things had to be done. But first, I moved the ‘Home’ folder to another position on the desktop.

From here on in this blog, for simplicity, I will no longer mention login and welcome screens after using the vagrant up command.

Automate some more

Of course, because I am using vagrant. All the changes I make by hand, will be lost when I recreate this virtual machine again.

So, I tried to automate as much as possible.

I right clicked on the dashboard and choose ‘Display Settings’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 80

Then, I navigated to ‘Date & Time’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 81

Here I could see the ‘Time Zone’ setting was not right for me.

Next, from the VirtualBox menu, I selected Devices | Shared Clipboard

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 82

Here I could see the ‘Shared Clipboard’ setting was not right for me.

Next, from the VirtualBox menu, I selected Devices | Drag and Drop

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 83

Here I could see the ‘Drag and Drop’ setting was not right for me.

I also wanted to use a shared folder.

Shared folders enable you to share data between the host system and guests. To use shared folders, you must first install the Oracle VM VirtualBox Guest Additions software on the guest OS.

The shared folder is associated with a share name and the full path name of the folder or directory on the host system. The share name is a unique name within the namespace of the host OS.
[https://www.virtualbox.org/manual/ch08.html#vboxmanage-sharedfolder]

I opted for using the using the config.vm.synced_folder method.

In order to change all these settings, I changed the content of Vagrantfile to:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_nodejs" do |ubuntu_vsc_nodejs|
    
    config.vm.synced_folder "C:\\My\\AMIS\\MySharedFolder", "/mnt/mysharedfolder", automount: true
    
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code and Node.js"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    end
    
  end

end

[https://www.virtualbox.org/manual/ch08.html#vboxmanage-cmd-overview]

Remark about config.vm.synced_folder:
Configures synced folders on the machine, so that folders on your host machine can be synced to and from the guest machine. Please see the page on synced folders for more information on how this setting works.
[https://www.vagrantup.com/docs/vagrantfile/machine_settings]

Synced Folders:
Synced folders enable Vagrant to sync a folder on the host machine to the guest machine, allowing you to continue working on your project’s files on your host machine, but use the resources in the guest machine to compile or run your project.

By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant.

Read the basic usage page to get started with synced folders.
[https://www.vagrantup.com/docs/synced-folders]

Basic Usage, Configuration:
Synced folders are configured within your Vagrantfile using the config.vm.synced_folder method.
[https://www.vagrantup.com/docs/synced-folders/basic_usage]

I changed the content of my ubuntu_etc.sh script to:
[in bold, I highlighted the changes]

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

sudo apt update
sudo apt upgrade -y
echo "**** Begin installing ubuntu-desktop"
sudo apt install ubuntu-desktop -y
sudo timedatectl set-timezone Europe/Amsterdam
echo "**** End installing ubuntu-desktop"

echo "**** End installing Ubuntu, etc"

I used the following command on the Windows Command Prompt: vagrant up

With the following output (only showing the relevant parts):

==> ubuntu_vsc_nodejs: Mounting shared folders...
    ubuntu_vsc_nodejs: /mnt/mysharedfolder => C:/My/AMIS/MySharedFolder

Now, I wanted to check the settings I automated.

So, I right clicked on the dashboard and choose ‘Display Settings’.

Then, I navigated to ‘Date & Time’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 84

This time, the ‘Time Zone’ setting was correct.

Next, from the VirtualBox menu, I selected Devices | Shared Folders | Shared Folders Settings…

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 85

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 86

Here, I could see, my shared folder was set correctly.

In order to check the content of the folder, I right clicked on the dashboard and choose ‘Open in Terminal’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 87

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 88

I used the following command to list the folder content:

ls /mnt/mysharedfolder

With the following output:

dummy.txt

This matched the folder on my Windows laptop.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 89

Then, I closed the Terminal.

Next, from the VirtualBox menu, I selected Devices | Shared Clipboard.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 90

I could see, it was set correctly to ‘Bidrectional’.

Remark about Shared Clipboard:
You can select here whether the clipboard of the guest OS should be shared with that of your host. If you select Bidirectional, then Oracle VM VirtualBox will always make sure that both clipboards contain the same data. If you select Host to Guest or Guest to Host, then Oracle VM VirtualBox will only ever copy clipboard data in one direction.
[https://www.virtualbox.org/manual/ch03.html#generalsettings]

Next, from the VirtualBox menu, I selected Devices | Drag and Drop.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 91

I could see, it was set correctly to ‘Bidrectional’.

Remark about Drag and Drop:
This setting enables support for drag and drop. Select an object, such as a file, from the host or guest and directly copy or open it on the guest or host. Multiple drag and drop modes for a VM enable restricting of access in either direction.
[https://www.virtualbox.org/manual/ch03.html#generalsettings]

Finally, I closed the system, via the VirtualBox menu, File | Close | Save the machine state.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 92

Installing Visual Studio Code

For installing Visual Studio Code on Ubuntu, I followed the instructions “Visual Studio Code on Linux, Installation”:

https://code.visualstudio.com/docs/setup/linux#_debian-and-ubuntu-based-distributions

Remark about Node.js in the Visual Studio Code installation instructions:
Node.js is a popular platform and runtime for easily building and running JavaScript applications. It also includes npm, a Package Manager for Node.js modules. You’ll see Node.js and npm mentioned frequently in our documentation and some optional VS Code tooling requires Node.js (for example, the VS Code extension generator).

If you’d like to install Node.js on Linux, see Installing Node.js via package manager to find the Node.js package and installation instructions tailored to your Linux distribution. You can also install and support multiple versions of Node.js by using the Node Version Manager.

To learn more about JavaScript and Node.js, see our Node.js tutorial, where you’ll learn about running and debugging Node.js applications with VS Code.

I changed the content of my ubuntu_etc.sh script to:
[in bold, I highlighted the changes]

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

sudo apt update
sudo apt upgrade -y
echo "**** Begin installing ubuntu-desktop"
sudo apt install ubuntu-desktop -y
sudo timedatectl set-timezone Europe/Amsterdam
echo "**** End installing ubuntu-desktop"

echo "**** Begin installing Visual Studio Code"
#Install the apt repository and signing key to enable auto-updating using the system's package manager
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

#Update the package cache and install the package
sudo apt install apt-transport-https
sudo apt update
sudo apt install code
echo "**** End installing Visual Studio Code"

echo "**** End installing Ubuntu, etc"

I used the following command on the Windows Command Prompt: vagrant up

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_nodejs' up with 'virtualbox' provider...
==> ubuntu_vsc_nodejs: Importing base box 'generic/ubuntu2204'...
...
    ubuntu_vsc_nodejs: **** Begin installing Ubuntu, etc
...
    ubuntu_vsc_nodejs: **** Begin installing ubuntu-desktop
...
    ubuntu_vsc_nodejs: **** End installing ubuntu-desktop
    ubuntu_vsc_nodejs: **** Begin installing Visual Studio Code
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: wget is already the newest version (1.21.2-2ubuntu1).
    ubuntu_vsc_nodejs: gpg is already the newest version (2.2.27-3ubuntu2.1).
    ubuntu_vsc_nodejs: gpg set to manually installed.
    ubuntu_vsc_nodejs: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: The following NEW packages will be installed:
    ubuntu_vsc_nodejs:   apt-transport-https
    ubuntu_vsc_nodejs: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs: Need to get 1,510 B of archives.
    ubuntu_vsc_nodejs: After this operation, 169 kB of additional disk space will be used.
    ubuntu_vsc_nodejs: Get:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.6 [1,510 B]
    ubuntu_vsc_nodejs: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_nodejs: Fetched 1,510 B in 0s (5,602 B/s)
    ubuntu_vsc_nodejs: Selecting previously unselected package apt-transport-https.
(Reading database ... 204649 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../apt-transport-https_2.4.6_all.deb ...
    ubuntu_vsc_nodejs: Unpacking apt-transport-https (2.4.6) ...
    ubuntu_vsc_nodejs: Setting up apt-transport-https (2.4.6) ...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Pending kernel upgrade!
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Running kernel version:
    ubuntu_vsc_nodejs:   5.15.0-41-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Diagnostics:
    ubuntu_vsc_nodejs:   The currently running kernel version is not the expected kernel version 5.15.0-43-generic.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Services to be restarted:
    ubuntu_vsc_nodejs:  systemctl restart cron.service
    ubuntu_vsc_nodejs:  systemctl restart haveged.service
    ubuntu_vsc_nodejs:  systemctl restart ifplugd.service
    ubuntu_vsc_nodejs:  systemctl restart irqbalance.service
    ubuntu_vsc_nodejs:  systemctl restart multipathd.service
    ubuntu_vsc_nodejs:  systemctl restart packagekit.service
    ubuntu_vsc_nodejs:  systemctl restart polkit.service
    ubuntu_vsc_nodejs:  systemctl restart rsyslog.service
    ubuntu_vsc_nodejs:  systemctl restart snapd.service
    ubuntu_vsc_nodejs:  systemctl restart ssh.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-journald.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-networkd.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-resolved.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-udevd.service
    ubuntu_vsc_nodejs:  systemctl restart udisks2.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Service restarts being deferred:
    ubuntu_vsc_nodejs:  systemctl restart ModemManager.service
    ubuntu_vsc_nodejs:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_nodejs:  systemctl restart getty@tty1.service
    ubuntu_vsc_nodejs:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-logind.service
    ubuntu_vsc_nodejs:  systemctl restart user@1000.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No containers need to be restarted.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No user sessions are running outdated binaries.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_nodejs: Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
    ubuntu_vsc_nodejs: Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
    ubuntu_vsc_nodejs: Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
    ubuntu_vsc_nodejs: Get:5 https://packages.microsoft.com/repos/code stable InRelease [10.4 kB]
    ubuntu_vsc_nodejs: Get:6 https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 DEP-11 Metadata [423 kB]
    ubuntu_vsc_nodejs: Get:7 https://packages.microsoft.com/repos/code stable/main amd64 Packages [98.5 kB]
    ubuntu_vsc_nodejs: Get:8 https://packages.microsoft.com/repos/code stable/main armhf Packages [99.4 kB]
    ubuntu_vsc_nodejs: Get:9 https://packages.microsoft.com/repos/code stable/main arm64 Packages [99.7 kB]
    ubuntu_vsc_nodejs: Get:10 https://mirrors.edge.kernel.org/ubuntu jammy/main DEP-11 48x48 Icons [100.0 kB]
    ubuntu_vsc_nodejs: Get:11 https://mirrors.edge.kernel.org/ubuntu jammy/main DEP-11 64x64 Icons [148 kB]
    ubuntu_vsc_nodejs: Get:12 https://mirrors.edge.kernel.org/ubuntu jammy/main DEP-11 64x64@2 Icons [15.8 kB]
    ubuntu_vsc_nodejs: Get:13 https://mirrors.edge.kernel.org/ubuntu jammy/universe amd64 DEP-11 Metadata [3,559 kB]
    ubuntu_vsc_nodejs: Get:14 https://mirrors.edge.kernel.org/ubuntu jammy/universe DEP-11 48x48 Icons [3,447 kB]
    ubuntu_vsc_nodejs: Get:15 https://mirrors.edge.kernel.org/ubuntu jammy/universe DEP-11 64x64 Icons [7,609 kB]
    ubuntu_vsc_nodejs: Get:16 https://mirrors.edge.kernel.org/ubuntu jammy/universe DEP-11 64x64@2 Icons [69.3 kB]
    ubuntu_vsc_nodejs: Get:17 https://mirrors.edge.kernel.org/ubuntu jammy/multiverse amd64 DEP-11 Metadata [42.1 kB]
    ubuntu_vsc_nodejs: Get:18 https://mirrors.edge.kernel.org/ubuntu jammy/multiverse DEP-11 48x48 Icons [42.7 kB]
    ubuntu_vsc_nodejs: Get:19 https://mirrors.edge.kernel.org/ubuntu jammy/multiverse DEP-11 64x64 Icons [193 kB]
    ubuntu_vsc_nodejs: Get:20 https://mirrors.edge.kernel.org/ubuntu jammy/multiverse DEP-11 64x64@2 Icons [214 B]
    ubuntu_vsc_nodejs: Get:21 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 DEP-11 Metadata [91.4 kB]
    ubuntu_vsc_nodejs: Get:22 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main DEP-11 48x48 Icons [26.2 kB]
    ubuntu_vsc_nodejs: Get:23 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main DEP-11 64x64 Icons [38.2 kB]
    ubuntu_vsc_nodejs: Get:24 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Get:25 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe amd64 DEP-11 Metadata [120 kB]
    ubuntu_vsc_nodejs: Get:26 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe DEP-11 48x48 Icons [40.9 kB]
    ubuntu_vsc_nodejs: Get:27 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe DEP-11 64x64 Icons [54.8 kB]
    ubuntu_vsc_nodejs: Get:28 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Get:29 https://mirrors.edge.kernel.org/ubuntu jammy-updates/multiverse amd64 DEP-11 Metadata [940 B]
    ubuntu_vsc_nodejs: Get:30 https://mirrors.edge.kernel.org/ubuntu jammy-updates/multiverse DEP-11 48x48 Icons [1,867 B]
    ubuntu_vsc_nodejs: Get:31 https://mirrors.edge.kernel.org/ubuntu jammy-updates/multiverse DEP-11 64x64 Icons [2,497 B]
    ubuntu_vsc_nodejs: Get:32 https://mirrors.edge.kernel.org/ubuntu jammy-updates/multiverse DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Get:33 https://mirrors.edge.kernel.org/ubuntu jammy-backports/universe amd64 DEP-11 Metadata [12.5 kB]
    ubuntu_vsc_nodejs: Get:34 https://mirrors.edge.kernel.org/ubuntu jammy-backports/universe DEP-11 48x48 Icons [2,686 B]
    ubuntu_vsc_nodejs: Get:35 https://mirrors.edge.kernel.org/ubuntu jammy-backports/universe DEP-11 64x64 Icons [7,651 B]
    ubuntu_vsc_nodejs: Get:36 https://mirrors.edge.kernel.org/ubuntu jammy-backports/universe DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Get:37 https://mirrors.edge.kernel.org/ubuntu jammy-security/main amd64 DEP-11 Metadata [11.4 kB]
    ubuntu_vsc_nodejs: Get:38 https://mirrors.edge.kernel.org/ubuntu jammy-security/main DEP-11 48x48 Icons [5,952 B]
    ubuntu_vsc_nodejs: Get:39 https://mirrors.edge.kernel.org/ubuntu jammy-security/main DEP-11 64x64 Icons [8,219 B]
    ubuntu_vsc_nodejs: Get:40 https://mirrors.edge.kernel.org/ubuntu jammy-security/main DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Get:41 https://mirrors.edge.kernel.org/ubuntu jammy-security/universe amd64 DEP-11 Metadata [608 B]
    ubuntu_vsc_nodejs: Get:42 https://mirrors.edge.kernel.org/ubuntu jammy-security/universe DEP-11 48x48 Icons [29 B]
    ubuntu_vsc_nodejs: Get:43 https://mirrors.edge.kernel.org/ubuntu jammy-security/universe DEP-11 64x64 Icons [29 B]
    ubuntu_vsc_nodejs: Get:44 https://mirrors.edge.kernel.org/ubuntu jammy-security/universe DEP-11 64x64@2 Icons [29 B]
    ubuntu_vsc_nodejs: Fetched 16.4 MB in 5s (3,214 kB/s)
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: All packages are up to date.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: The following NEW packages will be installed:
    ubuntu_vsc_nodejs:   code
    ubuntu_vsc_nodejs: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs: Need to get 85.2 MB of archives.
    ubuntu_vsc_nodejs: After this operation, 359 MB of additional disk space will be used.
    ubuntu_vsc_nodejs: Get:1 https://packages.microsoft.com/repos/code stable/main amd64 code amd64 1.70.0-1659589288 [85.2 MB]
    ubuntu_vsc_nodejs: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_nodejs: Fetched 85.2 MB in 17s (5,001 kB/s)
    ubuntu_vsc_nodejs: Selecting previously unselected package code.
(Reading database ... 204653 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../code_1.70.0-1659589288_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking code (1.70.0-1659589288) ...
    ubuntu_vsc_nodejs: Setting up code (1.70.0-1659589288) ...
    ubuntu_vsc_nodejs: Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
    ubuntu_vsc_nodejs: Processing triggers for shared-mime-info (2.1-2) ...
    ubuntu_vsc_nodejs: Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
    ubuntu_vsc_nodejs: Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Pending kernel upgrade!
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Running kernel version:
    ubuntu_vsc_nodejs:   5.15.0-41-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Diagnostics:
    ubuntu_vsc_nodejs:   The currently running kernel version is not the expected kernel version 5.15.0-43-generic.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Services to be restarted:
    ubuntu_vsc_nodejs:  systemctl restart cron.service
    ubuntu_vsc_nodejs:  systemctl restart haveged.service
    ubuntu_vsc_nodejs:  systemctl restart ifplugd.service
    ubuntu_vsc_nodejs:  systemctl restart irqbalance.service
    ubuntu_vsc_nodejs:  systemctl restart multipathd.service
    ubuntu_vsc_nodejs:  systemctl restart packagekit.service
    ubuntu_vsc_nodejs:  systemctl restart polkit.service
    ubuntu_vsc_nodejs:  systemctl restart rsyslog.service
    ubuntu_vsc_nodejs:  systemctl restart ssh.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-journald.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-networkd.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-resolved.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-udevd.service
    ubuntu_vsc_nodejs:  systemctl restart udisks2.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Service restarts being deferred:
    ubuntu_vsc_nodejs:  systemctl restart ModemManager.service
    ubuntu_vsc_nodejs:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_nodejs:  systemctl restart getty@tty1.service
    ubuntu_vsc_nodejs:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-logind.service
    ubuntu_vsc_nodejs:  systemctl restart user@1000.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No containers need to be restarted.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No user sessions are running outdated binaries.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_nodejs: **** End installing Visual Studio Code
    ubuntu_vsc_nodejs: **** End installing Ubuntu, etc

In order to check if Visual Studio Code was installed successfully, I clicked on the ‘Show Applications’ icon at the bottom left of the dashboard.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 93

I navigated to the second tab.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 94

Next, I left clicked on the ‘Visual Studio Code’ icon, to start the program.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 95

I could see, the program started.
For now, I left it at that and closed Visual Studio Code (via File | Exit).

Finally, I closed the system, via the VirtualBox menu, File | Close | Save the machine state.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 96

Installing Node.js

For installing Node.js on Ubuntu, I followed the instructions “Installing Node.js via package manager, Debian and Ubuntu based Linux distributions”:

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

There you can see:

Node.js binary distributions are available from NodeSource.
[https://github.com/nodesource/distributions/blob/master/README.md]

From there I navigated to “Installation instructions”:

https://github.com/nodesource/distributions/blob/master/README.md#debinstall

I followed these instructions.

So, I changed the content of my ubuntu_etc.sh script to:
[in bold, I highlighted the changes]

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

sudo apt update
sudo apt upgrade -y

echo "**** Begin installing ubuntu-desktop"
sudo apt install ubuntu-desktop -y
sudo timedatectl set-timezone Europe/Amsterdam
echo "**** End installing ubuntu-desktop"

echo "**** Begin installing Visual Studio Code"
#Install the apt repository and signing key to enable auto-updating using the system's package manager
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

#Update the package cache and install the package
sudo apt install apt-transport-https
sudo apt update
sudo apt install code
echo "**** End installing Visual Studio Code"

echo "**** Begin installing Node.js"
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
echo "**** End installing Node.js"

echo "**** End installing Ubuntu, etc"

I used the following command on the Windows Command Prompt: vagrant up

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_nodejs' up with 'virtualbox' provider...
==> ubuntu_vsc_nodejs: Importing base box 'generic/ubuntu2204'...
...
    ubuntu_vsc_nodejs: **** Begin installing Ubuntu, etc
...
    ubuntu_vsc_nodejs: **** Begin installing ubuntu-desktop
...
    ubuntu_vsc_nodejs: **** End installing ubuntu-desktop
    ubuntu_vsc_nodejs: **** Begin installing Visual Studio Code
...
    ubuntu_vsc_nodejs: **** End installing Visual Studio Code
    ubuntu_vsc_nodejs: **** Begin installing Node.js
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Installing the NodeSource Node.js 18.x repo...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Populating apt-get cache...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: + apt-get update
    ubuntu_vsc_nodejs: Hit:1 https://packages.microsoft.com/repos/code stable InRelease
    ubuntu_vsc_nodejs: Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_nodejs: Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
    ubuntu_vsc_nodejs: Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
    ubuntu_vsc_nodejs: Hit:5 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Confirming "jammy" is supported...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: + curl -sLf -o /dev/null 'https://deb.nodesource.com/node_18.x/dists/jammy/Release'
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Adding the NodeSource signing key to your keyring...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Creating apt sources list file for the NodeSource Node.js 18.x repo...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: + echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main' > /etc/apt/sources.list.d/nodesource.list
    ubuntu_vsc_nodejs: + echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main' >> /etc/apt/sources.list.d/nodesource.list
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Running `apt-get update` for you...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: + apt-get update
    ubuntu_vsc_nodejs: Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_nodejs: Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
    ubuntu_vsc_nodejs: Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
    ubuntu_vsc_nodejs: Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
    ubuntu_vsc_nodejs: Get:5 https://deb.nodesource.com/node_18.x jammy InRelease [4,563 B]
    ubuntu_vsc_nodejs: Hit:6 https://packages.microsoft.com/repos/code stable InRelease
    ubuntu_vsc_nodejs: Get:7 https://deb.nodesource.com/node_18.x jammy/main amd64 Packages [771 B]
    ubuntu_vsc_nodejs: Fetched 5,334 B in 1s (5,507 B/s)
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Run `sudo apt-get install -y nodejs` to install Node.js 18.x and npm
    ubuntu_vsc_nodejs: ## You may also need development tools to build native addons:
    ubuntu_vsc_nodejs:      sudo apt-get install gcc g++ make
    ubuntu_vsc_nodejs: ## To install the Yarn package manager, run:
    ubuntu_vsc_nodejs:      curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
    ubuntu_vsc_nodejs:      echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    ubuntu_vsc_nodejs:      sudo apt-get update && sudo apt-get install yarn
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Reading package lists...
    ubuntu_vsc_nodejs: Building dependency tree...
    ubuntu_vsc_nodejs: Reading state information...
    ubuntu_vsc_nodejs: The following NEW packages will be installed:
    ubuntu_vsc_nodejs:   nodejs
    ubuntu_vsc_nodejs: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_nodejs: Need to get 28.3 MB of archives.
    ubuntu_vsc_nodejs: After this operation, 179 MB of additional disk space will be used.
    ubuntu_vsc_nodejs: Get:1 https://deb.nodesource.com/node_18.x jammy/main amd64 nodejs amd64 18.7.0-deb-1nodesource1 [28.3 MB]
    ubuntu_vsc_nodejs: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_nodejs: Fetched 28.3 MB in 9s (3,204 kB/s)
    ubuntu_vsc_nodejs: Selecting previously unselected package nodejs.
(Reading database ... 206177 files and directories currently installed.)
    ubuntu_vsc_nodejs: Preparing to unpack .../nodejs_18.7.0-deb-1nodesource1_amd64.deb ...
    ubuntu_vsc_nodejs: Unpacking nodejs (18.7.0-deb-1nodesource1) ...
    ubuntu_vsc_nodejs: Setting up nodejs (18.7.0-deb-1nodesource1) ...
    ubuntu_vsc_nodejs: Processing triggers for man-db (2.10.2-1) ...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Pending kernel upgrade!
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Running kernel version:
    ubuntu_vsc_nodejs:   5.15.0-41-generic
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Diagnostics:
    ubuntu_vsc_nodejs:   The currently running kernel version is not the expected kernel version 5.15.0-43-generic.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Services to be restarted:
    ubuntu_vsc_nodejs:  systemctl restart cron.service
    ubuntu_vsc_nodejs:  systemctl restart haveged.service
    ubuntu_vsc_nodejs:  systemctl restart ifplugd.service
    ubuntu_vsc_nodejs:  systemctl restart irqbalance.service
    ubuntu_vsc_nodejs:  systemctl restart multipathd.service
    ubuntu_vsc_nodejs:  systemctl restart packagekit.service
    ubuntu_vsc_nodejs:  systemctl restart polkit.service
    ubuntu_vsc_nodejs:  systemctl restart rsyslog.service
    ubuntu_vsc_nodejs:  systemctl restart ssh.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-journald.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-networkd.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-resolved.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-udevd.service
    ubuntu_vsc_nodejs:  systemctl restart udisks2.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Service restarts being deferred:
    ubuntu_vsc_nodejs:  systemctl restart ModemManager.service
    ubuntu_vsc_nodejs:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_nodejs:  systemctl restart getty@tty1.service
    ubuntu_vsc_nodejs:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_nodejs:  systemctl restart systemd-logind.service
    ubuntu_vsc_nodejs:  systemctl restart user@1000.service
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No containers need to be restarted.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No user sessions are running outdated binaries.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: ## Installing the NodeSource Node.js 18.x repo...
    ubuntu_vsc_nodejs: **** End installing Node.js
    ubuntu_vsc_nodejs: **** End installing Ubuntu, etc

In order to check if Node.js was installed successfully, I right clicked on the dashboard and choose ‘Open in Terminal’ (as I described before).

Then, I used the following command:

node --version

With the following output:

v18.7.0

Next, I used the following command:

npm –version

With the following output

8.15.0

So, it looked like the installation of Node.js and npm was successful.

For me this was enough automation so far. On my Windows laptop, I had an environment with Ubuntu Desktop, Visual Studio Code and Node.js, available within an Oracle VirtualBox appliance with the help of Vagrant.

Of course, I needed all of this for a TypeScript training. So, to be sure that everything would work, I continued with the installation of TypeScript. But these steps I will do manually.

For this, I used the ‘Getting started’ instructions from the training and I also had a look at ‘TypeScript in Visual Studio Code’.
[https://code.visualstudio.com/docs/languages/typescript]

For more information about TypeScript, please see the TypeScript Documentation.
[https://www.typescriptlang.org/docs/]

Installing TypeScript

In order to make a working directory, in the terminal (I opened before), I used the following commands:

mkdir /home/vagrant/mywork
cd /home/vagrant/mywork

To create the file package.json, I used the following command:

npm init --yes

With the following output:

Wrote to /home/vagrant/mywork/package.json:

{
  "name": "mywork",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

In the output above, you can see the contents of file package.json.

All npm packages contain a file, usually in the project root, called package.json – this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project’s dependencies. It can also contain other metadata such as a project description, the version of the project in a particular distribution, license information, even configuration data – all of which can be vital to both npm and to the end users of the package. The package.json file is normally located at the root directory of a Node.js project.
[https://nodejs.org/en/knowledge/getting-started/npm/what-is-the-file-package-json/]

In order to install TypeScript, in the terminal, I used the following command:

npm install --save-dev typescript

With the following output:

added 1 package, and audited 2 packages in 1m

found 0 vulnerabilities

To check the TypeScript version (via the TypeScript compiler), I used the following command:

tsc --version

With the following output:

Version 4.7.4

To show the folder structure used by npm, I used the following command:

ls -latr ./node_modules/typescript

With the following output:

total 108
drwxrwxr-x  2 vagrant vagrant  4096 Aug  8 20:07 bin
-rw-rw-r--  1 vagrant vagrant  3920 Aug  8 20:07 package.json
drwxrwxr-x  3 vagrant vagrant  4096 Aug  8 20:07 loc
-rw-rw-r--  1 vagrant vagrant  2781 Aug  8 20:07 SECURITY.md
-rw-rw-r--  1 vagrant vagrant  5376 Aug  8 20:07 README.md
-rw-rw-r--  1 vagrant vagrant   333 Aug  8 20:07 CODE_OF_CONDUCT.md
-rw-rw-r--  1 vagrant vagrant  8483 Aug  8 20:07 AUTHORS.md
drwxrwxr-x 15 vagrant vagrant  4096 Aug  8 20:07 lib
-rw-rw-r--  1 vagrant vagrant  9197 Aug  8 20:07 LICENSE.txt
-rw-rw-r--  1 vagrant vagrant   812 Aug  8 20:07 CopyrightNotice.txt
-rw-rw-r--  1 vagrant vagrant 37767 Aug  8 20:07 ThirdPartyNoticeText.txt
drwxrwxr-x  5 vagrant vagrant  4096 Aug  8 20:07 .
drwxrwxr-x  4 vagrant vagrant  4096 Aug  8 20:07 ..

Remark about folder structures used by npm:
Local install (default): puts stuff in ./node_modules of the current package root.
[https://docs.npmjs.com/cli/v8/configuring-npm/folders]

To create the file tsconfig.json, I used the following command:

tsc --init

With the following output:

Created a new tsconfig.json with:                                               
                                                                             TS 
  target: es2016
  module: commonjs
  strict: true
  esModuleInterop: true
  skipLibCheck: true
  forceConsistentCasingInFileNames: true

You can learn more at https://aka.ms/tsconfig

This is the contents of file tsconfig.json:

{
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig to read more about this file */

    /* Projects */
    // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
    // "composite": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */
    // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */
    // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */
    // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */
    // "disableReferencedProjectLoad": true,             /* Reduce the number of projects loaded automatically by TypeScript. */

    /* Language and Environment */
    "target": "es2016",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
    // "lib": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */
    // "jsx": "preserve",                                /* Specify what JSX code is generated. */
    // "experimentalDecorators": true,                   /* Enable experimental support for TC39 stage 2 draft decorators. */
    // "emitDecoratorMetadata": true,                    /* Emit design-type metadata for decorated declarations in source files. */
    // "jsxFactory": "",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
    // "jsxFragmentFactory": "",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
    // "jsxImportSource": "",                            /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
    // "reactNamespace": "",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
    // "noLib": true,                                    /* Disable including any library files, including the default lib.d.ts. */
    // "useDefineForClassFields": true,                  /* Emit ECMAScript-standard-compliant class fields. */
    // "moduleDetection": "auto",                        /* Control what method is used to detect module-format JS files. */

    /* Modules */
    "module": "commonjs",                                /* Specify what module code is generated. */
    // "rootDir": "./",                                  /* Specify the root folder within your source files. */
    // "moduleResolution": "node",                       /* Specify how TypeScript looks up a file from a given module specifier. */
    // "baseUrl": "./",                                  /* Specify the base directory to resolve non-relative module names. */
    // "paths": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */
    // "rootDirs": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */
    // "typeRoots": [],                                  /* Specify multiple folders that act like './node_modules/@types'. */
    // "types": [],                                      /* Specify type package names to be included without being referenced in a source file. */
    // "allowUmdGlobalAccess": true,                     /* Allow accessing UMD globals from modules. */
    // "moduleSuffixes": [],                             /* List of file name suffixes to search when resolving a module. */
    // "resolveJsonModule": true,                        /* Enable importing .json files. */
    // "noResolve": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

    /* JavaScript Support */
    // "allowJs": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
    // "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */
    // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

    /* Emit */
    // "declaration": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
    // "declarationMap": true,                           /* Create sourcemaps for d.ts files. */
    // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */
    // "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */
    // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
    // "outDir": "./",                                   /* Specify an output folder for all emitted files. */
    // "removeComments": true,                           /* Disable emitting comments. */
    // "noEmit": true,                                   /* Disable emitting files from a compilation. */
    // "importHelpers": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
    // "importsNotUsedAsValues": "remove",               /* Specify emit/checking behavior for imports that are only used for types. */
    // "downlevelIteration": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
    // "sourceRoot": "",                                 /* Specify the root path for debuggers to find the reference source code. */
    // "mapRoot": "",                                    /* Specify the location where debugger should locate map files instead of generated locations. */
    // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */
    // "inlineSources": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */
    // "emitBOM": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
    // "newLine": "crlf",                                /* Set the newline character for emitting files. */
    // "stripInternal": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
    // "noEmitHelpers": true,                            /* Disable generating custom helper functions like '__extends' in compiled output. */
    // "noEmitOnError": true,                            /* Disable emitting files if any type checking errors are reported. */
    // "preserveConstEnums": true,                       /* Disable erasing 'const enum' declarations in generated code. */
    // "declarationDir": "./",                           /* Specify the output directory for generated declaration files. */
    // "preserveValueImports": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

    /* Interop Constraints */
    // "isolatedModules": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */
    // "allowSyntheticDefaultImports": true,             /* Allow 'import x from y' when a module doesn't have a default export. */
    "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
    // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
    "forceConsistentCasingInFileNames": true,            /* Ensure that casing is correct in imports. */

    /* Type Checking */
    "strict": true,                                      /* Enable all strict type-checking options. */
    // "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
    // "strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
    // "strictFunctionTypes": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
    // "strictBindCallApply": true,                      /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
    // "strictPropertyInitialization": true,             /* Check for class properties that are declared but not set in the constructor. */
    // "noImplicitThis": true,                           /* Enable error reporting when 'this' is given the type 'any'. */
    // "useUnknownInCatchVariables": true,               /* Default catch clause variables as 'unknown' instead of 'any'. */
    // "alwaysStrict": true,                             /* Ensure 'use strict' is always emitted. */
    // "noUnusedLocals": true,                           /* Enable error reporting when local variables aren't read. */
    // "noUnusedParameters": true,                       /* Raise an error when a function parameter isn't read. */
    // "exactOptionalPropertyTypes": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */
    // "noImplicitReturns": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */
    // "noFallthroughCasesInSwitch": true,               /* Enable error reporting for fallthrough cases in switch statements. */
    // "noUncheckedIndexedAccess": true,                 /* Add 'undefined' to a type when accessed using an index. */
    // "noImplicitOverride": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */
    // "noPropertyAccessFromIndexSignature": true,       /* Enforces using indexed accessors for keys declared using an indexed type. */
    // "allowUnusedLabels": true,                        /* Disable error reporting for unused labels. */
    // "allowUnreachableCode": true,                     /* Disable error reporting for unreachable code. */

    /* Completeness */
    // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
    "skipLibCheck": true                                 /* Skip type checking all .d.ts files. */
  }
}

I used the following command to list the directory contents:

ls -latr

With the following output:

total 32
drwxr-x--- 16 vagrant vagrant  4096 Aug  8 19:59 ..
-rw-rw-r--  1 vagrant vagrant   984 Aug  8 20:07 package-lock.json
-rw-rw-r--  1 vagrant vagrant   275 Aug  8 20:07 package.json
drwxrwxr-x  4 vagrant vagrant  4096 Aug  8 20:07 node_modules
-rw-rw-r--  1 vagrant vagrant 11298 Aug  8 20:11 tsconfig.json
drwxrwxr-x  3 vagrant vagrant  4096 Aug  8 20:11 .

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.
[https://www.typescriptlang.org/docs/handbook/tsconfig-json.html]

Using TypeScript in Visual Studio Code

Next, I wanted to use TypeScript in Visual Studio Code, using the instructions from the TypeScript training.

I had the change the contents of file tsconfig.json.
I clicked on the ‘Files’ icon at the left of the dashboard.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 97

Then, I navigated (via Other Locations | Computer | home | vagrant | mywork) to the directory mywork:

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 98

Next, I changed the contents of file tsconfig.json (only showing the lines I changed) via a right click | Open With Text Editor on the file:

"target": "es2019",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */

"sourceMap": true,                                   /* Create source map files for emitted JavaScript files. */

"outDir": "dist",                                    /* Specify an output folder for all emitted files. */

Then, I closed the Files window.

This time, in order to start Visual Studio Code, I used the following command:

code

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 99

I selected ‘Light’ and clicked on ‘Mark Done’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 100

Next, I maximized the screen.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 101

I clicked on the Explorer icon and then on Open Folder.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 102

I selected the newly created working directory mywork.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 103

In the pop-up I checked the checkbox and clicked on ‘Yes, I trust the authors’.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 104

In the Explorer tree, I could now see the folder structure of working directory mywork.
Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 105

I needed to create a new folder.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 106

So, I clicked on the ‘New Folder’ icon, and created a folder with the name ‘src’.

Next, I needed to create a new file.
With a right click | new File , in the src folder, I created file HelloWorld.ts.

And I added the following code:

class HelloWorld {
    static sayHello() {
    console.log('Hello world');
    }
    }
    HelloWorld.sayHello();

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 107

In order to compile this TypeScript code, I opened the Integrated Terminal (via View | Terminal).

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 108

On the terminal, I used the following command:

tsc src/HelloWorld.ts

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 109

This created a JavaScript file HelloWorld.js, with the following content:

var HelloWorld = /** @class */ (function () {
    function HelloWorld() {
    }
    HelloWorld.sayHello = function () {
        console.log('Hello world');
    };
    return HelloWorld;
}());
HelloWorld.sayHello();

Next, on the terminal, I used the following command:

node src/HelloWorld.js

With the following output:

Hello world

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 110

Next, I deleted the file src/HelloWorld.js.

After that, I selected File | Auto Save.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 111

Then, on the terminal, in order to watch input files, I used the following command:
[https://www.typescriptlang.org/docs/handbook/compiler-options.html]

tsc --watch

With the following output:

[8:15:58 PM] Starting compilation in watch mode...

[8:15:59 PM] Found 0 errors. Watching for file changes.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 112

As you can see, this command also made directory dist visible in the Explorer tree.

The watch option compiles any .ts TypeScript file in my src directory into a.js JavaScript file and stores them in my dist (outDir setting in file tsconfig.json) directory.

I changed the content of a file HelloWorld.ts to:
[in bold, I highlighted the changes]

var HelloWorld = /** @class */ (function () {
    function HelloWorld() {
    }
    HelloWorld.sayHello = function () {
        console.log('Hello world. Greetings from AMIS.');
    };
    return HelloWorld;
}());
HelloWorld.sayHello();

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 113

Then, I clicked on directory dist in the Explorer tree and opened file HelloWorld.js. This also had a changed contents:
[in bold, I highlighted the changes]

"use strict";
var HelloWorld = /** @class */ (function () {
    function HelloWorld() {
    }
    HelloWorld.sayHello = function () {
        console.log('Hello world. Greetings from AMIS.');
    };
    return HelloWorld;
}());
HelloWorld.sayHello();
//# sourceMappingURL=HelloWorld.js.map

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 114

Then I ran the TypeScript code using Visual Studio Code, via Run | Run Without Debugging.

In order to see the result, I clicked on the ‘’debug console’ tab, and could see the following output:

/usr/bin/node ./dist/HelloWorld.js
Hello world. Greetings from AMIS.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 115

So, it looked like TypeScript was working successful also.

Finally, I closed the system, via the VirtualBox menu, File | Close | Save the machine state.

Installing Ubuntu Desktop 22.04 LTS, Visual Studio Code and Node.js on a virtual machine using Vagrant and Oracle VirtualBox lameriks 2022 08 116

So, that is it. In this article I described, installing Ubuntu Desktop with the help of Vagrant, including Visual Studio Code and Node.js. I also described some manual steps to install and try out TypeScript in Visual Studio Code, using the instructions from the TypeScript training.

You can find the code, belonging to my article, here:
https://github.com/marclameriks/amis-technology-blog-2022-08-2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.