This guide provides step-by-step instructions for installing Node.js, TypeScript, and ts-node and the app dependencies on your machine.
- Go to the official Node.js website at https://nodejs.org/en/download/ in your web browser.
- Choose the appropriate version of Node.js for your operating system (Windows, macOS, or Linux) and download the installer.
- Run the installer with administrative privileges and follow the on-screen instructions to install Node.js on your machine.
- Open a command-line interface (CLI) or terminal on your machine.
- Run the following command to install TypeScript globally using npm, the Node.js package manager:
- Wait for the installation to complete.
npm install -g typescript
- Open a command-line interface (CLI) or terminal on your machine.
- Run the following command to install ts-node globally using npm:
- Wait for the installation to complete.
npm install -g ts-node
After completing the installation steps, you can verify if Node.js, TypeScript, and ts-node are installed correctly on your machine.
- Open a command-line interface (CLI) or terminal on your machine.
- Run the following commands to check the versions of Node.js, TypeScript, and ts-node:
- If you see the versions of Node.js, TypeScript, and ts-node printed in the output, it means that the installation was successful.
node -v
tsc -v
ts-node -v
After making sure that you have Node.js, TypeScript and ts-node installed it's finally possible to install the app dependencies.
- Open a command-line interface (CLI) or terminal on your machine.
- Get inside the app folder
- Execute the following command:
npm i
or
npm install
After installing the app dependencies it is finally possible to run the app using the command
npm start
This command will execute the app with the default settings ( port = 3000, auth_file = auth.bank).
There are a couple of pre-defined scripts that can be execute, this scripts are in the file package.json that is the file that also has the app dependencies. To run the scripts execute the following command:
npm run <scriptname>
You can also run the app giving your prefered parameters. To do so you have to give the program the inputs:
ts-node bank.ts [-s] [-p]
The -p argument corresponds to the server port number and the -s name of the auth file.