Start Your Business!

Stay updated with the latest tips and tricks to start your online business. It's completely free.

Migrating Code From Javascript To Typescript (NodeJS) - JungleWorks
  • Blog

Migrating Code From Javascript To Typescript (NodeJS)

Make your NodeJS Typescript code Production Ready

Add Typescript To your existing project

  1. npm install -g typescript
  2. tsc -i– this will create tsconfig.json file
  3. Add following code into jsconfig.json file

Points to take note of

  1. Make sure that all of your typescript code that you want to convert to typescript is inside src folder.
  2. Start converting each file to typescript by renaming the extension to .ts and then convert the code to typescript.
  3. Once you have converted all the files to typescript remove set "allowJs": false in compilerOptions .

Running Code in Production

  1. Once you are done with converting the code. Type tsc this will convert the entire code in src folder to javascript in dist folder.
  2. 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

Related Resources

No Comments »

Leave a Reply

Jungleworks