New Node – Typescript project checklist

Assuming Node, npm, nvm are all installed and updated.

1) npm init -y : Create the package.json file.
2) npm install typescript --save-dev : Install the typescript compiler
3) npx tsc --init: create tsconfig.json file

Now we want to automate our *.ts transpilation into javascript.

4) npm install ts-node --save-dev :
In package.json, under scripts:
"scripts": {
"start": "ts-node src/index.ts",
"build": "tsc"

5) npm install ts-node-dev --save-dev :
In package.json, under scripts:
"scripts": {
"start": "ts-node-dev --respawn src/index.ts",
"build": "tsc"

Note: choose either 4 or 5. 5 will enable hot-reloading of any changes to *.ts files when you do npm run start. With 4, you need to do npm run start to transpile *.ts file each time you make changes to them.

6) Install express server: npm install express --save
7) Install type definitions for nodejs: npm install @types/node --save-dev
8) Install type definitions for express: npm install @types/express --save-dev
When I install a package, I also make it a point to install the associated type definitions for that package. Like above, I installed the type definitions for node and express. All type definitions will appear as @types/ in package.json file

Tek Shinobi
Author: Tek Shinobi

Hiya Ninjas, I am the ninja who invented the fire, wheel, science, technology and everything intelligent this humanity has ever experienced since its evolution from monkeys and germs. Actually, above is a partial list. I also was involved with the Big Bang that created this universe. What was it like before the Big Bang is so secret that if I tell you, I will have to turn you into a hobbit and force you to be my gardener. Okay. Sayonanra, Namaste Tek Shinobi

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *