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
withnpm --init
.Install the Typescript as a dependency.
Create a config file for Typescript
tsconfig.json
, withnpx tsc --init
.
Transpile the Typescript code with
npx tsc
.The transipled
.js
will be at theoutDir
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
, wheredist
is theoutDir
specified andmain
is themain.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