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

No Comments

You can leave the first : )

Leave a Reply

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