- Open your web browser and go to Node.js website.
- Click on the "LTS" version download button to download the Node.js installer.
- Run the installer and follow the on-screen instructions, using the default settings.
- Open your terminal (Command Prompt or PowerShell on Windows).
- Run the following command to install TypeScript globally:
- For Windows users:
npm install -g typescript
- For Mac users:
sudo npm install -g typescript
- For Windows users:
- Go to VSCode download page.
- Download the appropriate version for your operating system.
- Run the installer and follow the on-screen instructions.
- Open VSCode and open the integrated terminal (
View
>Terminal
). - Navigate to your project folder using the
cd
command. - Initialize a TypeScript project with the command:
tsc --init
- Open Windows PowerShell as an administrator.
- Set the execution policy with the command:
Set-ExecutionPolicy RemoteSigned
- In the terminal, create a
package.json
file with the command:npm init -y
- Create a new TypeScript file in your project directory (e.g.,
index.ts
). - Write your TypeScript code in this file:
console.log("This is my first line of code");
- In the terminal, run the command:
tsc
- After transpilation, you'll find a corresponding JavaScript file in your project directory.
- Run the JavaScript file using Node.js with the command:
node index.js
- You should see the output:
This is my first line of code