New Project

Tips for initializing a new project blank project

What you need to start a project from zero.

  • Start the node config file package.json with npm --init.

  • Install the Typescript as a dependency.

    • Create a config file for Typescript tsconfig.json, with npx tsc --init.

  • Transpile the Typescript code with npx tsc.

    • The transipled .js will be at the outDir path.

  • Then for last you just run the Javascript code.

Automating the transpilation and execution

At the package.json, you can create a new script:

  • tsc && node dist/main, where dist is the outDir specified and main is the main.js or the starting execution script.

OR

You can install ts-node, which is a Typescript dependency for running Typescript directly.

  • npm install ts-node.

  • Then just run ts-node main.ts.

And if you install nodemon it will also recognize Typescript with ts-node, and keep running the Typescript application.

Last updated