Make your NodeJS Typescript code Production Ready
Add Typescript To your existing project
npm install -g typescript
tsc -i
– this will create tsconfig.json file- Add following code into jsconfig.json file
Points to take note of
- Make sure that all of your typescript code that you want to convert to typescript is inside
src
folder. - Start converting each file to typescript by renaming the extension to .ts and then convert the code to typescript.
- Once you have converted all the files to typescript remove set
"allowJs": false
incompilerOptions
.
Running Code in Production
- Once you are done with converting the code. TypeÂ
tsc
 this will convert the entire code inÂsrc
 folder to javascript inÂdist
 folder. - Now to run your code in production use the following commandÂ
pm2 start dist/app.js -i 0
Author: Raviteja
Visit the link to read more from Raviteja: https://medium.com/@raviteja.nitj
Subscribe to stay ahead with the latest updates and entrepreneurial insights!
Subscribe to our newsletter
Get access to the latest industry & product insights.