A simple tool that creates totally empty nodejs app configured with typescript with just one command.
If you dont want to read readme. Just execute the below
npx config-node-tsc
[!NOTE] I would recommend you to run any one of the commands below in your empty project folder since it initializes clean empty nodejs project configured with typescript.
It will initialize package.json file with default values or update your existing package.json.
It will initialize tsconfig.json file with required fields and remove all the comments. Your code will be transpiled inside
./dist
folder after building
npx config-node-tsc
This will create clean empty nodejs app configured with typescript. It will install typescript and @types/node as dev dependencies
Your package.json will look like this -
{
"name": "my-project",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"build": "npx tsc",
"prestart": "npm run build",
"start": "node dist/server.js",
"watch": "tsc -w",
"dev": "node --watch dist/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/node": "^22.5.4",
"typescript": "^5.6.2"
}
}
tsconfig.json file will look like this -
{
"compilerOptions": {
"target": "es2020",
"module": "nodenext",
"moduleResolution": "nodenext",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Your folder structure will look like this -
npx config-node-tsc --express
This will create clean empty nodejs app configured with typescript and express. It will install typescript, @types/node, @types/express as dev dependencies, and Express as dependencies
Your package.json file will look like this -
{
"name": "my-project",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"build": "npx tsc",
"prestart": "npm run build",
"start": "node dist/server.js",
"watch": "tsc -w",
"dev": "node --watch dist/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"express": "^4.19.2"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/node": "^22.5.4",
"typescript": "^5.6.2"
}
}
To build and transpile your Typescript code to Javascript, use npm run build
.
It will transpile all the code inside ./dist
folder.
Use npm run watch
to keep watching for Typescript changes and transpile it.
Use npm run dev
on a seperate terminal to keep watching for actual javascript code inside dist
folder