Install TypeScript on AlmaLinux: A Practical Project Setup
To install TypeScript on AlmaLinux, start with a supported Node.js runtime and add the compiler to your project as a development dependency. This keeps the compiler version with the code and makes local and CI builds easier to reproduce. You do not need a global compiler or root privileges for the project setup.
This walkthrough creates a small command-line project. An existing application may already have its own framework, package manager and module settings; follow those conventions rather than replacing its configuration with a tutorial.
Table of Contents
Install TypeScript on AlmaLinux: 1. Check AlmaLinux, Node.js and npm
cat /etc/os-release
node --version
npm --version
command -v node
command -v npm
If Node.js is missing, inspect the packages available from your approved repositories:
dnf info nodejs npm
On a machine where these packages provide the supported version your project needs, an administrator can install them with:
sudo dnf install nodejs npm
Review the proposed packages before accepting. Repository choices vary across AlmaLinux releases. Do not assume that a module-stream command copied from an older release applies to every system, or reset an existing stream without reviewing the applications that use it.
Check the Node.js release schedule and your dependencies’ runtime requirements. As reviewed in October 2026, Node.js 22 and 24 are LTS lines, while Node.js 20 has reached upstream end of life. Distribution maintenance policies can differ, so assess the package source as well as the major version.
2. Create a project-local TypeScript installation
Run the following as your ordinary development user in a new directory:
Before you install TypeScript on AlmaLinux, confirm which Node.js and npm versions the project expects.
mkdir typescript-demo
cd typescript-demo
npm init -y
npm install --save-dev --save-exact typescript
npx tsc --version
The compiler is recorded in devDependencies. The exact version and lockfile capture the chosen dependency state. Review package lifecycle scripts and dependency sources under your normal supply-chain policy. Avoid using sudo npm install to solve a project ownership problem.
3. Add a small, explicit configuration
Create tsconfig.json with this minimal configuration. It uses a simple CommonJS output so the first example does not depend on an application framework:
{
"compilerOptions": {
"target": "ES2022",
"module": "CommonJS",
"rootDir": "src",
"outDir": "dist",
"strict": true,
"noEmitOnError": true
},
"include": ["src/**/*.ts"]
}
Create a src directory and save this as src/main.ts:
const message: string = "Hello from TypeScript on AlmaLinux";
console.log(message);
Compile the project and execute its generated JavaScript:
npx tsc -p tsconfig.json
node dist/main.js
Expected output is the greeting above. Specifying a project reads its configuration; passing individual source filenames to the compiler is a different invocation and does not apply the same project-file workflow.
When you install TypeScript on AlmaLinux, commit the dependency and lockfile changes with the project.
4. Add build and type-check scripts
In package.json, add or merge the following scripts while retaining the other fields:
"scripts": {
"build": "tsc -p tsconfig.json",
"check": "tsc -p tsconfig.json --noEmit",
"start": "node dist/main.js"
}
npm run check
npm run build
npm start
A type-checking command should fail the build when the compiler reports errors. For example, assigning a number to the string variable is a useful temporary learning exercise. Restore the correct code afterward. Do not suppress compiler errors simply to make a pipeline green.
5. Reproduce the installation in CI
Commit the source, package.json, package-lock.json and configuration. Exclude generated dependency folders such as node_modules/ from source control. In a clean checkout with the agreed Node.js and npm versions, run:
npm ci
npm run check
npm run build
npm ci requires a lockfile consistent with the package manifest and replaces an existing dependency directory. It does not update the lockfile for you. Build jobs need development dependencies because that is where this compiler is installed.
Troubleshoot common setup problems
- tsc is not found: confirm the local dependency is installed and use an npm script or
npx tsc. - Permission denied: check project ownership and package-cache configuration instead of making the directory world-writable.
- Unexpected ESM/CommonJS errors: align the package
type, compiler module setting and runtime. Existing ESM projects need an appropriate configuration, not a blind copy of this sample. - npm ci fails: inspect manifest/lockfile differences and the npm version used to create the lockfile.
Install TypeScript on AlmaLinux: frequently asked questions
Does TypeScript validate API responses at runtime?
No. Static types are not a substitute for validating untrusted inputs. Add runtime validation where data enters the application.
How do I update or remove TypeScript?
Upgrade deliberately in a branch, review the compiler’s release notes, and run application tests. To remove the local dependency, use npm uninstall --save-dev typescript and review the manifest and lockfile changes.
Prerequisites and a clean setup
Before installing anything, update the system packages and confirm you have sudo access. TypeScript runs on Node.js, so install a supported Node release first, using your distribution’s module stream or the official packages, then check the versions of node and npm.
Install TypeScript per project, not just globally
A global install is convenient for quick tests, but a per-project install keeps each application on the version it was built with. In a project folder, run npm init, then add TypeScript as a development dependency and generate a configuration with the compiler’s init option. Commit the lock file for repeatable builds.
A minimal project layout
Keep source files in a src folder and compiled output in a dist folder. In the configuration file, set the output directory, choose a modern target, turn on strict mode and enable source maps for easier debugging.
Troubleshooting common problems
If the compiler is not found, check your PATH or run it through npx. Permission errors during global installs usually mean you should configure a user-level npm directory instead of using sudo. If types are missing for a library, install its matching types package.
If you plan to install TypeScript on AlmaLinux for a team, agree on one method first. To install TypeScript on AlmaLinux reliably, pin the Node version and the compiler version inside the project. Whenever you install TypeScript on AlmaLinux in a new environment, repeat the same documented steps and verify the compiler with a small test file. A written checklist makes it easy to install TypeScript on AlmaLinux the same way every time.
Frequently asked questions
Do I need a global install? No. A local dependency is safer for team projects.
Which Node version should I use? Use an actively supported long-term release.
How do I run compiled code? Compile with the compiler, then run the output file with node.
Key takeaways
- Install Node first and verify versions.
- Prefer per-project TypeScript installs.
- Enable strict mode from the start.
References and related reading
- TypeScript installation
- TSConfig reference
- Node.js release lifecycle
- npm ci reference
- Git workflow for beginners
Related reading: CentOS 7 to AlmaLinux 8: The cPanel ELevate Guide · Website Development: Skills, Process and Career Paths
Keep exploring: See all Linux and developer guides.





Leave a Reply