How To Install TypeScript on AlmaLinux 9
In this tutorial, we will show you how to install TypeScript on AlmaLinux 9. TypeScript is a typed superset of JavaScript that provides optional static typing, classes, interfaces, and other features to standard JavaScript. Using TypeScript can enhance developer productivity and code quality for large-scale JavaScript applications.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the TypeScript open-source programming language on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux or RHEL-based.
Prerequisites
- A server running one of the following operating systems: AlmaLinux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for TypeScript.
- TypeScript requires certain permissions that can only be granted to a superuser or a user with
sudo
privileges. Ensure that you have the necessary administrative access.
Install TypeScript on AlmaLinux 9
Step 1. First, update the system packages to their latest versions. This ensures that you have the latest security patches and system improvements. Use the following command to update your system:
sudo dnf clean all sudo dnf update
Step 2. Installing Node.js.
Node.js is available in the AlmaLinux 9 base repository. To install Node.js, run the following command:
sudo dnf install nodejs
To ensure Node.js and NPM (Node Package Manager) are installed successfully, run the following commands
node --version npm --version
Step 3. Installing TypeScript on AlmaLinux 9.
Next, install TypeScript globally using npm. A global installation makes TypeScript available for use across your entire system:
npm install -g typescript
After the installation, verify that TypeScript is correctly installed by checking its version:
tsc --version
This command should display the installed version of TypeScript.
Step 4. Configuring TypeScript.
After installing TypeScript, you need to create a tsconfig.json
file. This file is used to specify the root files and the compiler options required to compile your TypeScript project. To create a basic tsconfig.json
file, use the following command:
tsc --init
Step 5. Test the Installation,
With TypeScript installed and configured, test it out by creating a simple TypeScript file. main.ts
:
let message: string = "Hello World"; console.log({message});
Then compile with tsc
:
tsc main.ts
This will create a main.js
JavaScript file you can execute with Node:
node main.js
You should see “Hello World” printed, verifying TypeScript is working properly.
Congratulations! You have successfully installed TypeScript. Thanks for using this tutorial for installing TypeScript open-source programming language on your AlmaLinux 9 system. For additional help or useful information, we recommend you check the official TypeScript website.