Skip to content

Instantly share code, notes, and snippets.

@KiyonoKara
Last active January 5, 2024 03:26
Show Gist options
  • Save KiyonoKara/9960d88328a17757eeafddeace86605f to your computer and use it in GitHub Desktop.
Save KiyonoKara/9960d88328a17757eeafddeace86605f to your computer and use it in GitHub Desktop.
A guide on using TypeScript with WebStorm

ts-node WebStorm Guide

This is a simple guide to set up TypeScript in WebStorm. You don't need to have Node.js installed on your system if your IDE has an interpreter. NVM is also recommended if you'd like to stay up to date with all versions (if you'd like to manage all your versions).

Steps

  1. Open your WebStorm IDE and create a new project, you can create either an empty project (and configure it later) or a preconfigured Node.js project.
  2. Press Create.
    1
  3. Open the settings IntelliJ IDEA > Preferences for MacOS (⌘ + ,) or File > Settings for Windows or Linux.
  4. Go to Languages & Frameworks < Node.js and NPM.
  5. Click the + on the bottom left or press ⌘ + N on MacOS. 2
  6. On the available packages window, search for ts-node and install it.
  7. Once it's installed, exit the settings.
  8. Go to the top right and click on Add Configuration... and press the + symbol on the modal to add a configuration.

3 9. Select Node.js for your configuration. 4 10. In your Node Parameters, add this line (and a TS file you plan to run/debug):

--require ts-node/register
  1. Your configuration should something close to this: 5

Testing

  1. In your run/debug configuration(s), you can add a TypeScript file in the JavaScript file configuration as a path.
  2. Create a TypeScript file (if you haven't) or use an existing TypeScript file then run it.

You're all set now! Now you can run TypeScript code via the ts-node script in WebStorm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment