- Develop a simple command line calculator using TypeScipt, Node.js and Inquirer.
- Create a GitHub repository for the project and submit its URL in the project submission form.
First, open your terminal window and create a new project directory:
mkdir project_calculator
Then, navigate to this directory:
cd project_calculator
To start adding prompts to your Node.js scripts, you will need to install the inquirer package:
npm install ts-node typescript @types/inquirer --save-dev
inside actual dependenncies we need to install package:
npm install inquirer
open your terminal window and create a new directory:
mkdir src
go inside this directory with following command and crreate index.ts file inside it:
cd src
add following lines into package.json file:
"scripts": {
"start": "ts-node --esm ./src/index.ts",
"build": "tsc.cmd ./src/index.ts"
},
add following lines into package.json file:
"type": "module"
run following at project root directory:
tsc --init
change following inside tsconfig.json file:
{
"compilerOptions": {
"target": "es6",
"module": "ES6",
...
}
run following code at project root directory to execute node file or project file:
npm start or yarn start
you are now 'good to go', make logic of your first calculator inside index.ts file in your desired IDE:
if you have cloned this project just run following command:
npm intall or yarn add
to execute prewritten code inside index.tx run following command:
npm start or yarn start
after running above mentioned command list of four option will displayed on your cli:
in case you have completed your calculation cli will console answer, displayed in below snip: