Follow these steps to install Node.js (which includes npm) and the TypeScript compiler on Linux. The specific commands might vary slightly depending on your distribution.
General Steps (using package managers):
-
Update Package Lists:
- Debian/Ubuntu:
sudo apt update
- Fedora/CentOS/RHEL:
sudo dnf update # or sudo yum update
- Arch Linux:
sudo pacman -Syu
- Debian/Ubuntu:
-
Install Node.js and npm:
- Debian/Ubuntu (Recommended - using NodeSource):
(Replace
curl -sL [https://deb.nodesource.com/setup_lts.x](https://deb.nodesource.com/setup_lts.x) | sudo -E bash - sudo apt-get install -y nodejs
lts.x
with the desired LTS version, e.g.,setup_20.x
) - Debian/Ubuntu (Alternative):
(You might need
sudo apt install nodejs npm
sudo apt install nodejs-legacy
as well) - Fedora/CentOS/RHEL:
sudo dnf install nodejs npm # or sudo yum install nodejs npm
- Arch Linux:
sudo pacman -S node npm
- Debian/Ubuntu (Recommended - using NodeSource):
-
Verify Node.js and npm Installation:
-
Open your Terminal.
-
Run the following commands to check the installed versions:
node -v
Expected Output: A version number (e.g.,
v18.16.0
)npm -v
Expected Output: A version number (e.g.,
9.5.1
)
-
-
Install TypeScript Compiler:
- In the same Terminal window, run the following command to install TypeScript globally:
npm install -g typescript
- In the same Terminal window, run the following command to install TypeScript globally:
-
Verify TypeScript Installation:
- Run the following command to check the installed version of the TypeScript compiler:
Expected Output: A version number (e.g.,
tsc -v
Version 5.0.4
)
- Run the following command to check the installed version of the TypeScript compiler:
Now you have npm and the TypeScript compiler installed on your Linux system. Remember to adjust the installation commands based on your specific Linux distribution.